cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
newpbiuser01
Helper IV
Helper IV

Split a string into a list in DAX

Hello,

 

I am trying to split a string to create a list so I can flag all items that are part of my string and are found in the data table. Unfortunately I cannot do this in Power Query, so I'm trying to do this in a DAX measure. 

 

As as example, my string [List to Check] = "Strawberry, Grapes". 

 

I tried the following measure to split it into a list:

 

Measure =
VAR mymeasure =
    SUBSTITUTE ( [List to Check], ",", "|" )
VAR Mylen =
    PATHLENGTH ( mymeasure )
VAR mytable =
    ADDCOLUMNS (
        GENERATESERIES ( 1, mylen ),
        "mylist", VALUE ( PATHITEM ( mymeasure, [Value],TEXT ) )
    )
VAR mylist =
    SELECTCOLUMNS ( mytable, "list", [mylist] )
RETURN
   IF(MAX('Table - List'[Item]) IN mylist, "Yes", "No")

 

Data Table:

Item

Apple
Pear
Orange
Grapes
Watermelon
Strawberry

 

I get the following error: 

newpbiuser01_0-1693338273641.png

I can't figure out what I'm doing wrong! My list is not numerical, I have clearly specified that the value is text. Would anyone know what I'm doing wrong? I'd really appreciate any help!

Thank you!

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@newpbiuser01 why you are using VALUE function here :

 

VALUE ( PATHITEM ( mymeasure[Value],TEXT ) )



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

2 REPLIES 2
parry2k
Super User
Super User

@newpbiuser01 why you are using VALUE function here :

 

VALUE ( PATHITEM ( mymeasure[Value],TEXT ) )



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Hi @parry2k

 

I'm using the Value function to get the actual value of the string. You did point out correctly though! Once I remove the Value function, the measure works perfectly! Thank you so much. I couldn't understand why it wouldn't work!

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors