Forum Discussion
Applicable88
Impactful Individual
5 years agoMeasure to sum beyond row context with condition
Hello, summing values in the same row comes more natural, but now I have a problem where the values are always placed irregulary. For instance that is my sample table: Product ProcessNo Time1...
- 5 years ago
You should unpivot the Time columns in Power Query (name the Time references column "TimeRef" and the Value colum "Time")
Then create the following measures:
Measure1 = CALCULATE ( SUM ( 'Table'[Time] ), 'Table'[ProcessNo] IN { 1, 4 }, 'Table'[TimeRef] IN { "Time2", "Time3" } )Measure2 = VAR C1 = CALCULATE ( SUM ( 'Table'[Time] ), FILTER ( 'Table', 'Table'[ProcessNo] = 4 && 'Table'[TimeRef] = "Time2" ) ) VAR C2 = CALCULATE ( SUM ( 'Table'[Time] ), FILTER ( 'Table', 'Table'[ProcessNo] IN { 1, 4 } && 'Table'[TimeRef] = "Time3" ) ) RETURN C1 + C2To get:
I've attached a sample PBIX
- Anonymous5 years ago
Applicable88
Thank you for sharing the sample pbix. In your scenario, you could just create 2 calculated columns in Table2 using Related() to get the expected sum time.SumPrepTime = RELATED(Table1[PrepTime])SumProdtime = RELATED(Table1[ProdTime])Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.
vanessafvg
Community Champion
5 years agogive the following a try.
Measure 1 =
var time2 = CALCULATE(sum(Proceses[Time2]), ALLEXCEPT(Proceses,Proceses[Product]), Proceses[ProcessNo] in {1,4})
var time3 = CALCULATE(sum(Proceses[Time3]), ALLEXCEPT(Proceses,Proceses[Product]), Proceses[ProcessNo] in {1,4})
return time2 + time3
Measure 2 =
var time2 = CALCULATE(sum(Proceses[Time2]), ALLEXCEPT(Proceses,Proceses[Product]), Proceses[ProcessNo] = 4 )
var time3 = CALCULATE(sum(Proceses[Time3]), ALLEXCEPT(Proceses,Proceses[Product]), Proceses[ProcessNo] in {1,4})
return time2 + time3