Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Return1 value for multiple criteria

Hi there,

 

Been stuck on this for a while and appreciate any input;

 

I've a list of sales orders, with each order comprising of multiple order lines, and each order line can be pass or fail. 

However, I report based on the pass/fail status of orders, and if just one line fails, the whole order fails.

 

Example: 1 order number has 6 lines; 2 fail, 4 pass, but the order overall is a fail

 

How do I return a single pass/fail for each order? 

 

In excel I would sort by Pass/Fail column with fail on top, pass below, then remove duplicate sales order #'s (as it'd clear from top down, removing duplicate sales orders, and any duplicate "pass" results would be removed if a sales order with "fail" was found earlier in the column).

 

 

1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

For this test data, create two measures

11.png

fail n = CALCULATE(COUNT(Sheet5[status]),FILTER(ALLEXCEPT(Sheet5,Sheet5[order]),Sheet5[status]="fail"))

flag = IF([fail n]>0,"fail","pass")

Add them in a table visual

10.png

 

Best Regards

Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

8 REPLIES 8
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

For this test data, create two measures

11.png

fail n = CALCULATE(COUNT(Sheet5[status]),FILTER(ALLEXCEPT(Sheet5,Sheet5[order]),Sheet5[status]="fail"))

flag = IF([fail n]>0,"fail","pass")

Add them in a table visual

10.png

 

Best Regards

Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hi @v-juanli-msft Maggie, 

 

Would you be able to convert that code; 

Failed Orders = CALCULATE(COUNT('PD - Line'[Order Fail PD2]),FILTER(ALLEXCEPT('PD - Line','PD - Line'[Sales document]),'PD - Line'[Order Fail PD2]="Fail"))

 

Into a line that can be used within a custom column creation formula in PowerQuery? It works a dream in DAX, but need in PowerQuery to resolve an issue i'm having with remove duplicates (it's not consistent in it's choices), so think order level pass/fail would resolve over the contradictory line level pass/fail as the orders it's marking as pass when removing duplicates has both passing & failing lines, and it's choosing pass over fail despite ranking and sorting to stop this.

AnthonyTilley
Solution Sage
Solution Sage

I had a similar issue and just used a Max value to get the overall status in a matrix.

 

i assinged a value of 1 for pass and 2 for fail and then had a measure of

Maxstatus =Max(Orders[STATUS CODE])

 

when used in a matrix with Order id as the row header and the measure above means that if any line exsists with a fail the max value will be a 2. if there are no fail lines and all lines are pass then the max value will be 1

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




tex628
Community Champion
Community Champion

With a measure you should be able to do it with simply: 

Measure = IF(SELECTEDVALUE('Table'[Status]) = "Pass" ; "Pass" ; "Fail" )


Put it in a matrix with your orders and it should return fail on all orders that have fails.


Connect on LinkedIn
Anonymous
Not applicable

Unfortunately this shows which order line is pass or fail, but doesn't class an order as a whole as pass/fail (each order can contain both pass and fail lines, but if so, the order is failed).

 

 

tex628
Community Champion
Community Champion

Measure = 
VAR OrderNo = SELECTEDVALUE('Table'[OrderNumber])
Return
CALCULATE(
IF(SELECTEDVALUE('Table'[Status]) = "Pass" ; "Pass" ; "Fail" );
ALL('Table');
'Table'[OrderNumber] = OrderNo
)

Try this instead! 🙂


Connect on LinkedIn
Anonymous
Not applicable

this didn't work off the bat, and after changeing the last 2 semicolons with commas, it worked, but just gives a pass result, and no fails

tex628
Community Champion
Community Champion

@Anonymous Are you referring to my code? 


Connect on LinkedIn

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.