Forum Discussion
Matrix Visualization - Create Custom Total Column
- Anonymous1 year ago
Thanks for the reply from rajendraongole1, please allow me to provide another insight:
Hi, jerryr125
Thanks for reaching out to the Microsoft fabric community forum.Regarding the issue you raised, my solution is as follows:
You can use the UNION() function combined with an index column for sorting:
1.First, create a calculated table:
Table 2 = VAR f2 = ADDCOLUMNS( 'Table', "index", CALCULATE( COUNTROWS('Table'), ALLEXCEPT( 'Table', 'Table'[Product Name] ), 'Table'[Category] >= EARLIER('Table'[Category]) ) ) VAR f1 = SUMMARIZE( 'Table', 'Table'[Product Name], "Category", "FinalInv", "Amount", VAR c1 = CALCULATE( SUM('Table'[Amount]), ALLEXCEPT( 'Table', 'Table'[Product Name] ), 'Table'[Category] = "StartingInv" ) VAR c2 = CALCULATE( SUM('Table'[Amount]), ALLEXCEPT( 'Table', 'Table'[Product Name] ), 'Table'[Category] = "SoldInv" ) VAR c3 = CALCULATE( SUM('Table'[Amount]), ALLEXCEPT( 'Table', 'Table'[Product Name] ), 'Table'[Category] = "DefectInv" ) RETURN c1 - c2 - c3, "index", 4 ) RETURN UNION( f2, f1 )2.Next, sort based on the index column:
3.Here's my final result, which I hope meets your requirements.
4.For more details, please refer to:
How to put the row and column subtotals in front o... - Microsoft Fabric Community
Please find the attached pbix relevant to the case.
Best Regards,
Leroy Lu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi jerryr125 - Please check the attached pbix file.
- jerryr1251 year ago
Helper IV
Hi rajendraongole1 and thank you very much !
How do you set the visualization so that the FinalInv column appears at the end of matrix visualization (see image below). Any help is appreciated! Thanks - Jerry
- Anonymous1 year agoNot applicable
Thanks for the reply from rajendraongole1, please allow me to provide another insight:
Hi, jerryr125
Thanks for reaching out to the Microsoft fabric community forum.Regarding the issue you raised, my solution is as follows:
You can use the UNION() function combined with an index column for sorting:
1.First, create a calculated table:
Table 2 = VAR f2 = ADDCOLUMNS( 'Table', "index", CALCULATE( COUNTROWS('Table'), ALLEXCEPT( 'Table', 'Table'[Product Name] ), 'Table'[Category] >= EARLIER('Table'[Category]) ) ) VAR f1 = SUMMARIZE( 'Table', 'Table'[Product Name], "Category", "FinalInv", "Amount", VAR c1 = CALCULATE( SUM('Table'[Amount]), ALLEXCEPT( 'Table', 'Table'[Product Name] ), 'Table'[Category] = "StartingInv" ) VAR c2 = CALCULATE( SUM('Table'[Amount]), ALLEXCEPT( 'Table', 'Table'[Product Name] ), 'Table'[Category] = "SoldInv" ) VAR c3 = CALCULATE( SUM('Table'[Amount]), ALLEXCEPT( 'Table', 'Table'[Product Name] ), 'Table'[Category] = "DefectInv" ) RETURN c1 - c2 - c3, "index", 4 ) RETURN UNION( f2, f1 )2.Next, sort based on the index column:
3.Here's my final result, which I hope meets your requirements.
4.For more details, please refer to:
How to put the row and column subtotals in front o... - Microsoft Fabric Community
Please find the attached pbix relevant to the case.
Best Regards,
Leroy Lu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- polymathy20171 year ago
Advocate III
The goal of a forum like this is to educate users, not show how smart or creative you are in engineering solutions that a poster won't comprehend.
C'mon, man, read the room. He's clearly new to Power BI and doesn't understand it hardly at all, so you think the best solution is a very long DAX expression that includes table joins that he's surely not going to understand? Gotta put your thinking cap on before wasting bandwidth on a complicated solution.
The simplest way for you to achieve what you want is to pivot the category column in Power Query to create separate columns for starting inventory, sold inventory, and defective inventory and then run your aggregations across each column.
Of course, since he doesn't know how to arrive at an aggregated column total, even this simple approach may not be simple. He needs to learn some basic Power BI/DAX best practices. Sounds like he's trying to create something without knowing anything about the tool he's working with.