Forum Discussion
Incorrect Total in Column Matrix view
- Anonymous6 years ago
Hi Anonymous
I build two tables like yours to have a test.
Table1:
Table2:
Add two measures Volume and Unit Margin into Table1.
Unit Margin = SUM(Table2[Unit Margin])Volume = SUM(Table2[Volume])Then I build a measure and a calculated column to achieve your goal.
Calculated Column:
Actual Difference = VAR _FORMULA = ('Table1'[Unit Margin]-'Table1'[Loc Unit Margin])*'Table1'[Volume] RETURN _FORMULAMeasure:
Difference in Power Bi = VAR _Formula = ( [Unit Margin] - SUM ( Table1[Loc Unit Margin] ) ) * [Volume] RETURN IF ( HASONEVALUE ( Table1[Location] ), _Formula, SUMX ( SUMMARIZE ( Table1, Table1[Location], "_Formula", ( [Unit Margin] - SUM ( Table1[Loc Unit Margin] ) ) * [Volume] ), [_Formula] ) )Result:
You can download the pbix file from this link: Incorrect Total in Column Matrix view
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous , if they are from the same table it should be like
Sumx(Table,( [Unit Margin] - [Location Unit Margin])*[Volume])
for different tables please fice a row context using values or summarize with common dimension
amitchandak My Unit Margin & Volume is a measure & only Loc Unit Margin is a column. Hence the Sumx will not work in this scenario, right? Sorry, i should have mentioned that in the post.
- Anonymous6 years agoNot applicable
Hi Anonymous
I build two tables like yours to have a test.
Table1:
Table2:
Add two measures Volume and Unit Margin into Table1.
Unit Margin = SUM(Table2[Unit Margin])Volume = SUM(Table2[Volume])Then I build a measure and a calculated column to achieve your goal.
Calculated Column:
Actual Difference = VAR _FORMULA = ('Table1'[Unit Margin]-'Table1'[Loc Unit Margin])*'Table1'[Volume] RETURN _FORMULAMeasure:
Difference in Power Bi = VAR _Formula = ( [Unit Margin] - SUM ( Table1[Loc Unit Margin] ) ) * [Volume] RETURN IF ( HASONEVALUE ( Table1[Location] ), _Formula, SUMX ( SUMMARIZE ( Table1, Table1[Location], "_Formula", ( [Unit Margin] - SUM ( Table1[Loc Unit Margin] ) ) * [Volume] ), [_Formula] ) )Result:
You can download the pbix file from this link: Incorrect Total in Column Matrix view
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.