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 am trying to figure out how to implement this scenario with DAX.
Consider the following matrix with three columns
id | parameter | cost |
AB | Parameter 1 | 10 |
AC | Parameter 2 | 20 |
AD | Parameter 3 | 15 |
CA | Parameter 4 | 40 |
EF | Parameter 6 | 67 |
FE | Parameter 7 | 80 |
EF | Parameter 8 | 45 |
GA | Parameter 9 | 45 |
CA | Parameter 5 | 52 |
The ID column is the concatenation of two variables that can be combined. I would like to find in the table all the records in which the two variables are swapped among each other.
The final result needs to be
id | parameter | cost |
AC | Parameter 2 | 20 |
CA | Parameter 4 | 40 |
CA | Parameter 5 | 52 |
EF | Parameter 6 | 67 |
FE | Parameter 7 | 80 |
EF | Parameter 8 | 45 |
Thank you for your support
Solved! Go to Solution.
Hi, @flyingfox
You can try the following methods.
Column:
id2 = RIGHT('Table'[id],1)&LEFT('Table'[id],1)
Table:
New Table = UNION(VALUES('Table'[id]),VALUES('Table'[id2]))
Measure:
Count id =
CALCULATE (
COUNT ( 'New Table'[id] ),
FILTER ( ALL ( 'New Table' ), [id] = SELECTEDVALUE ( 'New Table'[id] ) )
)
Measure = IF([Count id]=1,0,1)
Drag Measure into the view to be displayed and set it equal to 1.
Is this the result you expect?
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I set up the secondary key in the model. It works. Thank you
Hi, @flyingfox
You can try the following methods.
Column:
id2 = RIGHT('Table'[id],1)&LEFT('Table'[id],1)
Table:
New Table = UNION(VALUES('Table'[id]),VALUES('Table'[id2]))
Measure:
Count id =
CALCULATE (
COUNT ( 'New Table'[id] ),
FILTER ( ALL ( 'New Table' ), [id] = SELECTEDVALUE ( 'New Table'[id] ) )
)
Measure = IF([Count id]=1,0,1)
Drag Measure into the view to be displayed and set it equal to 1.
Is this the result you expect?
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Dear Team_Charlotte,
thank you so much for your valuable support. You undestood my issue and you almost got the result because, I am sorry, I did not mention that each record in the master Table is associated to a date. Therefore dragging your interesting Measure into the view to be displayed and setting it equal to 1, it does not produce the desidered results because the filter does not work due to the missing date in the New Table. Could you help me, please?
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 |
---|---|
42 | |
21 | |
21 | |
14 | |
13 |
User | Count |
---|---|
43 | |
39 | |
33 | |
18 | |
17 |