Forum Discussion
PRORATE by drivers
- 7 years ago
Hi Anonymous,
Please refer to below steps, but it may not achieve your requirement completely.
In Query Editor mode, choose all "Business" columns and click "Unpivot columns" to convert table structure to below.
Apply changes, in Data view mode, create a calculated table.
Usage2 = UNION ( ADDCOLUMNS ( VALUES ( Cost[Plants] ), "Business", "Total", "Percentage", 1 ), Usage )Add [Business] from above 'Usage2' table into slicer. Add Usage2[Plants], Usage2[Business] and below measure into Matrix. Remember to turn off "Column Subtotals" under "Subtotals" option in Format pane.
cost by business = IF ( CALCULATE ( ISFILTERED ( Usage2[Business] ), ALLSELECTED ( Cost ) ), CALCULATE ( SUM ( Cost[Cost] ), FILTER ( ALLSELECTED ( Cost ), Cost[Plants] = SELECTEDVALUE ( Usage2[Plants] ) ) ) * SUM ( Usage2[Percentage] ), CALCULATE ( SUM ( Cost[Cost] ), FILTER ( ALLSELECTED ( Cost ), Cost[Plants] = SELECTEDVALUE ( Usage2[Plants] ) ) ) )If nothing is filtered, Matrix would show total cost as well as each business. To show total cost only, you need to select "Total" from slicer.
Best regards,
Yuliana Gu
Hi Anonymous,
Please refer to below steps, but it may not achieve your requirement completely.
In Query Editor mode, choose all "Business" columns and click "Unpivot columns" to convert table structure to below.
Apply changes, in Data view mode, create a calculated table.
Usage2 =
UNION (
ADDCOLUMNS ( VALUES ( Cost[Plants] ), "Business", "Total", "Percentage", 1 ),
Usage
)
Add [Business] from above 'Usage2' table into slicer. Add Usage2[Plants], Usage2[Business] and below measure into Matrix. Remember to turn off "Column Subtotals" under "Subtotals" option in Format pane.
cost by business =
IF (
CALCULATE ( ISFILTERED ( Usage2[Business] ), ALLSELECTED ( Cost ) ),
CALCULATE (
SUM ( Cost[Cost] ),
FILTER ( ALLSELECTED ( Cost ), Cost[Plants] = SELECTEDVALUE ( Usage2[Plants] ) )
)
* SUM ( Usage2[Percentage] ),
CALCULATE (
SUM ( Cost[Cost] ),
FILTER ( ALLSELECTED ( Cost ), Cost[Plants] = SELECTEDVALUE ( Usage2[Plants] ) )
)
)
If nothing is filtered, Matrix would show total cost as well as each business. To show total cost only, you need to select "Total" from slicer.
Best regards,
Yuliana Gu
awesome this has helped a lot, thank you so much!