Forum Discussion
Andy_Chandler
9 years agoFrequent Visitor
Calculating whether a service level has been met
I have individual rows that record the lead time for different part batches. Each part type has a service level requirement. If any part type fails to meet its service level, I want to calculate th...
- Anonymous9 years ago
OK, I found the flaws in my logic. My previous formula ignored row context all over the place. This version gives the results I was attempting before. I don't know if this will work in DirectQuery though, because it includes SUMMARIZE and ADDCOLUMNS. You might be able to get around that if you go into Options and check the box marked "Allow unrestricted measures in DirectQuery Mode."
Pass/Fail = IF( HASONEVALUE(Parts[Part Type]), VAR target = MIN(Parts[Target SLA]) / 100 VAR passfail = ADDCOLUMNS( SUMMARIZE( Parts, Parts[RowID] ), "pass", CALCULATE(MIN(Parts[Lead Time Achieved]) <= MIN(Parts[Lead Time Target])) ) RETURN IF( DIVIDE( COUNTROWS(FILTER(passfail, [pass] = TRUE)), COUNTROWS(passfail) ) >= target, "Pass", "Fail" ), VAR partscores = SUMMARIZE( Parts, Parts[Part Type], "score", VAR tg = CALCULATE(MIN(Parts[Target SLA])) / 100 RETURN IF( DIVIDE( CALCULATE( COUNTROWS( FILTER( ADDCOLUMNS( Parts, "pass", CALCULATE(MIN(Parts[Lead Time Achieved]) <= MIN(Parts[Lead Time Target])) ), [pass] = TRUE ) ) ), CALCULATE(COUNTROWS(Parts)) ) >= tg, "Pass", "Fail" ) ) RETURN FORMAT( DIVIDE( CALCULATE( DISTINCTCOUNT(Parts[Part Type]), FILTER(partscores, [score] = "Pass") ), DISTINCTCOUNT(Parts[Part Type]) ), "0%" ) & " Passed" )
Greg_Deckler
Community Champion
9 years agoJust create a third measure based on the previous two,
if(p1=false,false,if(p2=false,false,true)
psuedo-code.