Forum Discussion
ilTac
5 years agoFrequent Visitor
SUM based on specific condition
Hello everyone, i've been trying on this for a while and it seems i'm not able to do it. I think it should be simple but anyway: here's my database: I would like to see % of good pieces...
- 5 years ago
I tested this solution and it worked for my sample data set
Pieces Below Company Target :=Var BelowTarget =CALCULATE(CALCULATE(sum(DataTest[Pieces]), FILTER(DataTest, [% Good Pieces] < [Target])),all(DataTest))RETURNIF( [% Good Pieces] < [Target], BelowTarget)Pieces Above Company Target :=Var AboveTarget =CALCULATE(CALCULATE(sum(DataTest[Pieces]), FILTER(DataTest, [% Good Pieces] > [Target])),all(DataTest))RETURNIF( [% Good Pieces] > [Target], AboveTarget) - 5 years ago
thedatahiker
5 years agoMicrosoft Employee
Hi ilTac,
If I understand your question I think you just need is to alter the % good pieces measure in the IF statement to calculate the total for the entire company irrespective of date. You could also accomplish a similar result by using ALL(Table[Day]) instead of ALLEXCEPT but in this case, I think it makes more sense to be prescriptive on the total you want to include.
Pieces Above Company Target =
Var AboveTarget =
CALCULATE(
CALCULATE(sum(DataTest[Pieces]), FILTER(DataTest, [% Good Pieces] > [Target])),
all(DataTest)
)
RETURN
IF( CALCULATE([% Good Pieces], ALLEXCEPT(DataTest,DataTest[Company])) > [Target], AboveTarget)
thedatahiker
5 years agoMicrosoft Employee
ilTac Did I answer your question? Mark my post as a solution
- ilTac5 years agoFrequent Visitor