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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
abhi139
Frequent Visitor

How to transform & compare 2 columns having multiple values with delimiter

Hello All, I need your help in comparing two columns having delimiter seperated values, with transformation required based on 2nd table. I need to compare Column 1 and Column 2, both columns have delimiter seperated text values and also transform column 2 based on Table 2 (for comparison). 

The sequence/placement of values doesnt matter - e.g. Red is in first place in row 1 but equivalent value in Column 2 (C1) is in second place.  

Table 1

SrColumn1Column2 Column3 (Result)
1Red; Blue; Pink C2; C1; C3  Match
2Yellow; PinkC4  Mismatch
3Blue; RedC1;C2  Match

 

Table 2

Column1  Column2
Red  C1
Blue  C2
Pink  C3
Yellow  C4

 

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

Are you trying to do this in the query editor (using M) or in your model (using DAX)?

It's not super pretty, but you can do this with a custom column in the query editor. The code for that step would look something like this (assuming Column1 and Column2 have had spaces removed):

 

= Table.AddColumn(#"Previous Step", "Column3", (r) => if Table.SelectRows(Table2, each List.Contains(Text.Split(r[Column1], ";"), [Column1]))[Column2] = List.Sort(Text.Split(r[Column2], ";")) then "Match" else "Mismatch", type text)

 

This code checks if two lists are equal. The first list is Table2[Column2] where Table2 has been filtered to only include values from that specific row in Table1[Column1]. The second list is Table1[Column2] value in that row turned into a list by splitting on ";" and sorting alphabetically (to match the order in Table2).

View solution in original post

2 REPLIES 2
AlexisOlson
Super User
Super User

Are you trying to do this in the query editor (using M) or in your model (using DAX)?

It's not super pretty, but you can do this with a custom column in the query editor. The code for that step would look something like this (assuming Column1 and Column2 have had spaces removed):

 

= Table.AddColumn(#"Previous Step", "Column3", (r) => if Table.SelectRows(Table2, each List.Contains(Text.Split(r[Column1], ";"), [Column1]))[Column2] = List.Sort(Text.Split(r[Column2], ";")) then "Match" else "Mismatch", type text)

 

This code checks if two lists are equal. The first list is Table2[Column2] where Table2 has been filtered to only include values from that specific row in Table1[Column1]. The second list is Table1[Column2] value in that row turned into a list by splitting on ";" and sorting alphabetically (to match the order in Table2).

Thank you, the solution worked perfectly. 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.