The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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