Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi All, need help on writing DAX
the logic should be if that particular ID is only Failed - 0, only Success - 1, Success & failed - 2, Success & Failed & reprocess - 3
the expected column should be like below image.
Solved! Go to Solution.
@AntonioM , got the solution by using this DAX code
@AntonioM , I tried with the code which you provided, expected column is giving the result based on only status, but the condition is also to check based on ID & Status
Ex- if ID is 456 and failed, success & reprocess then 3
@lathaaa Could you show me what you're getting when you've tried that? The line
var statuses = CALCULATETABLE( VALUES('Table'[Status]), ALL('Table'[Status]) )should keep the filter on ID and check for all statuses. Do you have any other other columns in the table?
@AntonioM , got the solution by using this DAX code
when i try to filter on one ID and check for status, column check is the result but expected result should be as it is "True" & "blank" for that ID , it has to show 2 instead of 0 & 1
thank you
Please give this a try
Column =
var statuses = CALCULATETABLE( VALUES('Table'[Status]), ALL('Table'[Status]) )
return
SWITCH(
TRUE(),
CONTAINS(statuses,'Table'[Status], "reprocess") && CONTAINS(statuses,'Table'[Status], "Failed") && CONTAINS(statuses,'Table'[Status], "Success"),
3,
CONTAINS(statuses,'Table'[Status], "Failed") && CONTAINS(statuses,'Table'[Status], "Success"),
2,
CONTAINS(statuses,'Table'[Status], "Success"),
1,
CONTAINS(statuses,'Table'[Status], "Failed"),
0
)Which will give you
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 41 | |
| 38 | |
| 36 | |
| 31 | |
| 28 |
| User | Count |
|---|---|
| 128 | |
| 88 | |
| 79 | |
| 68 | |
| 63 |