Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
simona0808
Helper I
Helper I

Dax trim function

Hello everyone,

I am working on a project and I would like to ask for some help.

As you can see in the image the left column(injured body parts) is coming from a checklist and is stored in a list separated by ;#. Is there a chance to trim that and add every injured body part related to the id column separately? I just need it on separate lines so I can make a relationship with another table that stores the single body parts

simona0808_0-1683100291988.png

 

8 REPLIES 8
ValtteriN
Super User
Super User

Hi,

I am not 100% I follow but I assume you want to separate the list using ;# as delimiter and have the results show on different rows?

If you have access to powerquery I recommend doign this there like this:

ValtteriN_0-1683101283450.png

Right-click and select "split column by delimiter" -> Select custom and enter ;#

ValtteriN_1-1683101375921.png

Select created column and unpivot:

ValtteriN_2-1683101402385.png

ValtteriN_3-1683101413143.png



In dax you can do with e.g. using substitute function and some tricks. Here is an example blog of this by entreprisedna: Power BI Split Column By Delimiters In DAX (enterprisedna.co)

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/






Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thank you very much for your answer! Thats what I want. I tried your approach but it says that it cant be applied in direct query mode. 

In Directquery mode I am pretty sure this won't work and you will have to use dax option. If possible try changing your conenction to import/composite model then the original soltuion I provide should work.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Unfortunately, I am not able to change it due to customer requirements. Do you know how this can be done using Dax?

It can be done with dax for example like described in the blog I linked





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




I tried to implement the steps from the tutorial however I encountered an error that pathlength is not a function and can be used in a direct query mode( again the same problem)

Anonymous
Not applicable

Hi @simona0808 ,

What type of data source are you worked on? If you mean SQL or other type of Datasources which support T-SQL queries, I’d like to suggest you turn on the 'advanced option' -> 'SQL statemen' options in data connector to use custom T-SQL query to handle these conversions.

Tutorial: Connect to on-premises data in SQL Server - Power BI | Microsoft Learn

Regards,

Xiaoxin Sheng

I believe I need to use a SQL query to achieve my goal. Currently, I have a column in my database that contains multiple values per row, as it's derived from a checklist. However, for my Power BI report, I need to use a single value as a page-level filter. To do this, I would like to split the values in this column into separate rows so that each row contains only one value. Can you assist me in creating a SQL query to accomplish this task?

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.