Forum Discussion
common763
Helper III
6 years agoDifference instead of Total in PowerBI Matrix
I cant seem to find a solution to this online. Basically I have a matrix table that displays two columns and instead of showing the total all I want is to display the difference. Not sure how to do...
- 6 years ago
Hi common763 ,
Please create such a measure.
Measure = VAR x = CALCULATE( SUM(Sheet4[Number]), FILTER( ALLSELECTED(Sheet4), Sheet4[DATE] < MAX(Sheet4[DATE]) && Sheet4[FACILITY] = MAX(Sheet4[FACILITY]) ) ) VAR y = CALCULATE( SUM(Sheet4[Number]), FILTER( ALL(Sheet4), Sheet4[DATE] = MAX(Sheet4[DATE]) && Sheet4[FACILITY] = MAX(Sheet4[FACILITY]) ) ) RETURN IF( HASONEFILTER(Sheet4[DATE]), SUM(Sheet4[Number]), x-y )Best regards,
Lionel ChenIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-lionel-msft
Community Support
6 years agoHi common763 ,
Please create such a measure.
Measure =
VAR x =
CALCULATE(
SUM(Sheet4[Number]),
FILTER(
ALLSELECTED(Sheet4),
Sheet4[DATE] < MAX(Sheet4[DATE]) && Sheet4[FACILITY] = MAX(Sheet4[FACILITY])
)
)
VAR y =
CALCULATE(
SUM(Sheet4[Number]),
FILTER( ALL(Sheet4), Sheet4[DATE] = MAX(Sheet4[DATE]) && Sheet4[FACILITY] = MAX(Sheet4[FACILITY]) )
)
RETURN
IF(
HASONEFILTER(Sheet4[DATE]),
SUM(Sheet4[Number]),
x-y
)
Best regards,
Lionel Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Nijlal01
Helper I
5 years agoHi,
Great solution!
How should I change the code if the are more columns and if I want to have the difference value calculated correctly also if a column is expanded or collapsed. For example:
| FacilityGroup | Facility | 01/01/2020 | 01/05/2020 |
| 1 | A | 100 | 50 |
| 1 | B | 50 | 100 |
| 2 | C | 0 | 50 |
KR,
Lars