Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi, I've got two calculated columns, so a Power Query solution isn't feasible, and I don't really know where to start, or if it's possible to achieve my expected result. The two columns have data separated by commas, and I want to check if what's between the commas matches, even if the items are in a different order.
Here is a visual of what I'm looking for, let's say this table is called "test"
Calculated Column1 | Calculated Column2 | Expected Result |
ABC,DEFGH,IJ | IJ,ABC,DEFGH | Match |
XYZ,MNOPQR | LMN,TUVWXYZ | No Match |
Solved! Go to Solution.
This is annoying to do in DAX since there isn't a nice function to split the text. However, it's possible to abuse the PATH functions to accomplish this.
Expected Result =
VAR Path1 = SUBSTITUTE ( Concat[Calculated Column1], ",", "|" )
VAR Path2 = SUBSTITUTE ( Concat[Calculated Column2], ",", "|" )
VAR Len1 = PATHLENGTH ( Path1 )
VAR Len2 = PATHLENGTH ( Path2 )
VAR List1 = SELECTCOLUMNS ( GENERATESERIES ( 1, Len1 ), "Item", PATHITEM ( Path1, [Value] ) )
VAR List2 = SELECTCOLUMNS ( GENERATESERIES ( 1, Len2 ), "Item", PATHITEM ( Path2, [Value] ) )
RETURN
IF ( MAX ( Len1, Len2 ) = COUNTROWS ( INTERSECT ( List1, List2 ) ), "Match", "No Match" )
This turns each concatenation into a path and then constructs a list of each item in the path. Then if the intersection of these lists has as many items as each individual one, it's a match.
This would be much easier in Power Query. Is it possible to make your Calculated Columns there instead, so you can do this too there? Or is it indepent and you could do it there first?
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
This would be much easier in Power Query. Is it possible to make your Calculated Columns there instead, so you can do this too there? Or is it indepent and you could do it there first?
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
This is annoying to do in DAX since there isn't a nice function to split the text. However, it's possible to abuse the PATH functions to accomplish this.
Expected Result =
VAR Path1 = SUBSTITUTE ( Concat[Calculated Column1], ",", "|" )
VAR Path2 = SUBSTITUTE ( Concat[Calculated Column2], ",", "|" )
VAR Len1 = PATHLENGTH ( Path1 )
VAR Len2 = PATHLENGTH ( Path2 )
VAR List1 = SELECTCOLUMNS ( GENERATESERIES ( 1, Len1 ), "Item", PATHITEM ( Path1, [Value] ) )
VAR List2 = SELECTCOLUMNS ( GENERATESERIES ( 1, Len2 ), "Item", PATHITEM ( Path2, [Value] ) )
RETURN
IF ( MAX ( Len1, Len2 ) = COUNTROWS ( INTERSECT ( List1, List2 ) ), "Match", "No Match" )
This turns each concatenation into a path and then constructs a list of each item in the path. Then if the intersection of these lists has as many items as each individual one, it's a match.
Thank you so much! This works great
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
114 | |
101 | |
78 | |
75 | |
49 |
User | Count |
---|---|
145 | |
108 | |
107 | |
89 | |
61 |