Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
79 | |
78 | |
59 | |
36 | |
33 |
User | Count |
---|---|
94 | |
61 | |
56 | |
49 | |
41 |