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.
I'm looking for a calculated column function that will help me determine an overall status based on multiple rows of data.
My data looks something like this and I am looking to create the "Calculated Overall Status" column:
Name | Type | Status | Calculated Overall Status |
PT001 | g | Failed | Failed |
PT001 | s | Passed | Failed |
PT002 | g | Passed | Passed |
PT002 | s | Passed | Passed |
PT003 | g | Passed | Warning |
PT003 | s | Warning | Warning |
If a "Name" shows up more than once in the data, I want to look at all the statuses and mark them as "Passed" if they all passed, "Falied" if any of the statuses failed and Warning if there is a warning in any status.
If I'm not thinking of this correctly please send me in the right direction
Solved! Go to Solution.
You may try the DAX below.
Column =
SWITCH (
TRUE (),
ISEMPTY (
FILTER (
'Table',
'Table'[Name] = EARLIER ( 'Table'[Name] )
&& 'Table'[Status] <> "Passed"
)
), "Passed",
NOT (
ISEMPTY (
FILTER (
'Table',
'Table'[Name] = EARLIER ( 'Table'[Name] )
&& 'Table'[Status] = "Failed"
)
)
), "Failed",
NOT (
ISEMPTY (
FILTER (
'Table',
'Table'[Name] = EARLIER ( 'Table'[Name] )
&& 'Table'[Status] = "Warning"
)
)
), "Warning"
)
Hey,
try this DAX statement:
Column =
var _name = 'Table'[Name]
var theString = CONCATENATEX(FILTER(ALL('Table') , 'Table'[Name] = _name) , 'Table'[Status] , "|" , 'Table'[Status] , ASC)
return
SWITCH(
TRUE()
, PATHCONTAINS(theString , "Failed") , "Failed"
, PATHCONTAINS(theString , "Warning") , "Warning"
, "Passed"
)
This calculated column looks like your expected result:
What the DAX does is this:
Just switch the order of the rows
PATHCONTAINS( ... , "Failed") , "Failed"
PATHCONTAINS( ... , "WArning") , "Warning"
if "Warning" tops "Failed".
Hopefully this is what you are looking for.
Regards,
Tom
I see that your solution is working on the sample data and I even recreated it working myself but its not working on our production data. Can't explain why at this point... In the real data, every row is reporting Passed so I can only assume its defaulting to that. More to come
You may try the DAX below.
Column =
SWITCH (
TRUE (),
ISEMPTY (
FILTER (
'Table',
'Table'[Name] = EARLIER ( 'Table'[Name] )
&& 'Table'[Status] <> "Passed"
)
), "Passed",
NOT (
ISEMPTY (
FILTER (
'Table',
'Table'[Name] = EARLIER ( 'Table'[Name] )
&& 'Table'[Status] = "Failed"
)
)
), "Failed",
NOT (
ISEMPTY (
FILTER (
'Table',
'Table'[Name] = EARLIER ( 'Table'[Name] )
&& 'Table'[Status] = "Warning"
)
)
), "Warning"
)
User | Count |
---|---|
77 | |
76 | |
41 | |
29 | |
24 |
User | Count |
---|---|
96 | |
91 | |
52 | |
47 | |
46 |