Forum Discussion
Put subtotal column first matrix
good, I have this matrix and the subtotal column is the latter, I need it first
Hi, Syndicate_Admin
According to your description, you want to put the sub_total as first.
Total in the default Matrix is automatically generated and currently has no settings to place in the first column.
For your need , you can create a dimension column table in Power Query .
Here are the steps you can refer to :
(1)This is my test data:We can create a "Blank Query" in Power Query and enter this M code to create a dimension column table:
let Source = {"Total"} &List.Distinct(Table[Column]), #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error), #"Added Index" = Table.AddIndexColumn(#"Converted to Table", "Index", 1, 1, Int64.Type) in #"Added Index"(2)Then we can load the data to Power BI Desktop , then we can create a measure :
Measure = var _cur_column = MAX('Table 2'[Column1]) return IF( _cur_column = "Total" , CALCULATE( SUM('Table'[Value]) ) , CALCULATE(SUM('Table'[Value]) , 'Table'[Column] =_cur_column) )(3)Then we can put the fields we need on the visual and we can sort the 'Table 2 '[Column1] by the 'Table 2'[Index] column and now we can meet your need:
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
3 Replies
- Syndicate_AdminAdministrator
up
- v-yueyunzh-msftCommunity Support
Hi, Syndicate_Admin
According to your description, you want to put the sub_total as first.
Total in the default Matrix is automatically generated and currently has no settings to place in the first column.
For your need , you can create a dimension column table in Power Query .
Here are the steps you can refer to :
(1)This is my test data:We can create a "Blank Query" in Power Query and enter this M code to create a dimension column table:
let Source = {"Total"} &List.Distinct(Table[Column]), #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error), #"Added Index" = Table.AddIndexColumn(#"Converted to Table", "Index", 1, 1, Int64.Type) in #"Added Index"(2)Then we can load the data to Power BI Desktop , then we can create a measure :
Measure = var _cur_column = MAX('Table 2'[Column1]) return IF( _cur_column = "Total" , CALCULATE( SUM('Table'[Value]) ) , CALCULATE(SUM('Table'[Value]) , 'Table'[Column] =_cur_column) )(3)Then we can put the fields we need on the visual and we can sort the 'Table 2 '[Column1] by the 'Table 2'[Index] column and now we can meet your need:
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
- Syndicate_AdminAdministrator
THANK YOU!!