Forum Discussion
Anonymous
4 years agoNot applicable
How to sum specific rows based on slicer
dear all hi, i would like your support for an issue that i have in a chart where i present rates (basically it is the formula: cost divided to production volumes) per month. I have a column (in ta...
- 4 years ago
Hi Anonymous ,
Create 2 measures as below:
Measure2 = VAR vol36 = CALCULATE ( SUM ( Volumn2[Quantity] ), FILTER ( ALL ( Volumn2 ), 'Volumn2'[Produced Product ] = "36" && 'Volumn2'[Month] = MAX ( 'cost2'[Month] ) ) ) VAR volME = CALCULATE ( SUM ( Volumn2[Quantity] ), FILTER ( ALL ( Volumn2 ), 'Volumn2'[Produced Product ] = "ME" && 'Volumn2'[Month] = MAX ( 'cost2'[Month] ) ) ) VAR departA = CALCULATE ( SUM ( 'cost2'[Amount] ), FILTER ( ALL ( cost2 ), 'cost2'[Department ] = "department A" && 'cost2'[Month] = MAX ( 'cost2'[Month] ) ) ) VAR departB = CALCULATE ( SUM ( 'cost2'[Amount] ), FILTER ( ALL ( cost2 ), 'cost2'[Department ] = "department B" && 'cost2'[Month] = MAX ( 'cost2'[Month] ) ) ) VAR departC = CALCULATE ( SUM ( 'cost2'[Amount] ), FILTER ( ALL ( cost2 ), 'cost2'[Department ] = "department C" && 'cost2'[Month] = MAX ( 'cost2'[Month] ) ) ) VAR _departA = DIVIDE ( departA, vol36 ) VAR _departB = DIVIDE ( departB, volME ) VAR _departC = DIVIDE ( departC, volME ) VAR _total = IF ( "department A" IN FILTERS ( 'Table'[department] ), _departA, 0 ) + IF ( "department B" IN FILTERS ( 'Table'[department] ), _departB, 0 ) + IF ( "department C" IN FILTERS ( 'Table'[department] ), _departC, 0 ) RETURN IF ( ISINSCOPE ( 'Table'[department] ), SWITCH ( SELECTEDVALUE ( 'Table'[department] ), "department A", _departA, "department B", _departB, "department C", _departC ), _total )Measure3 = SUMX ( VALUES ( 'cost2'[Month] ), 'Table'[Measure 2] )And you will see:
For the updated .pbix file,pls see attached.
Best Regards,
KellyDid I answer your question? Mark my reply as a solution!
YukiK
4 years agoImpactful Individual
Please consider using DIVIDE() function. That'll catch divide-by-zero error and should help not show the value of infinity.
Hope this helps!