Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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
User | Count |
---|---|
76 | |
75 | |
46 | |
31 | |
27 |
User | Count |
---|---|
99 | |
89 | |
52 | |
48 | |
46 |