Forum Discussion
Matrix visual with difference calculation from total row
- 4 years ago
Hi Anonymous ,
Please create a new table.
Table = VAR newcapacity = CROSSJOIN ( Capacity, VALUES ( Train[Day] ) ) VAR UnionTab = UNION ( Train, SELECTCOLUMNS ( newcapacity, "Company", [Company], "Train", "Capacity", "Day", [Day], "Load", [Capacity] ) ) RETURN ADDCOLUMNS ( UnionTab, "Type", IF ( [Train] = "Capacity", "Capacity", "Train" ) )Then create these measures.
Load and Capacity = CALCULATE ( SUM ( 'Table'[Load] ), 'Table'[Company] = "Company A" )TotalValue = VAR diff = CALCULATE ( [Load and Capacity], 'Table'[Type] = "Train" ) - CALCULATE ( [Load and Capacity], 'Table'[Type] = "Capacity" ) RETURN IF ( ISFILTERED ( 'Table'[Type] ), [Load and Capacity], diff )If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Anonymous ,
Please create a new table.
Table =
VAR newcapacity =
CROSSJOIN ( Capacity, VALUES ( Train[Day] ) )
VAR UnionTab =
UNION (
Train,
SELECTCOLUMNS (
newcapacity,
"Company", [Company],
"Train", "Capacity",
"Day", [Day],
"Load", [Capacity]
)
)
RETURN
ADDCOLUMNS (
UnionTab,
"Type", IF ( [Train] = "Capacity", "Capacity", "Train" )
)
Then create these measures.
Load and Capacity =
CALCULATE ( SUM ( 'Table'[Load] ), 'Table'[Company] = "Company A" )TotalValue =
VAR diff =
CALCULATE ( [Load and Capacity], 'Table'[Type] = "Train" )
- CALCULATE ( [Load and Capacity], 'Table'[Type] = "Capacity" )
RETURN
IF ( ISFILTERED ( 'Table'[Type] ), [Load and Capacity], diff )
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.