Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
pbiuser1234
Helper I
Helper I

right to left matrix

Hello 

Is there any solution yet to align right to left a matrix?

If not, Is there a way to add a table group header (like in SSRS) to a table visualization?

I understand that in power bi, a group header can only be done with a matrix visualization - but I need to show it right to left.

Thank you 

1 ACCEPTED SOLUTION
PaulDBrown
Community Champion
Community Champion

Well this isn't perfect, but it's the closest I have come.

1) In Power Query, create the layout of the matrix using:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("fdCxCoAwDATQf8ncweYi6OwnOJYiFcRREB38e6GDFMI5JnkcR1ISlSBTubb9OJ+4zPf6De1BckgCRtXRnlE4OjYbZQW00oFRdTR2zOI3FqwBKjVG1VEwCkcjo+Zo+y1jXU1yfgE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Amount = _t, #"Sub-Category" = _t, Category = _t]),
    OrignalTable = Table.TransformColumnTypes(Source,{{"Amount", Int64.Type}, {"Sub-Category", type text}, {"Category", type text}}),
    #"Removed Other Columns" = Table.SelectColumns(OrignalTable,{"Category"}),
    #"Removed Duplicates" = Table.Distinct(#"Removed Other Columns"),
    #"Added Index" = Table.AddIndexColumn(#"Removed Duplicates", "Index", 1, 1, Int64.Type),
    CatIndex = Table.RenameColumns(#"Added Index",{{"Index", "CatIndex"}}),
    #"Merged Queries" = Table.NestedJoin(CatIndex, {"Category"}, OrignalTable, {"Category"}, "CatIndex.1", JoinKind.LeftOuter),
    #"Expanded CatIndex.1" = Table.ExpandTableColumn(#"Merged Queries", "CatIndex.1", {"Sub-Category"}, {"Sub-Category"}),
    #"Added Index1" = Table.AddIndexColumn(#"Expanded CatIndex.1", "Index", 1, 1, Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Added Index1", "Custom", each [CatIndex] + [Index]/1000),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Index"}),
    SubCatIndex = Table.RenameColumns(#"Removed Columns",{{"Custom", "SubCatIndex"}}),
    #"Removed Other Columns1" = Table.SelectColumns(SubCatIndex,{"Sub-Category", "SubCatIndex"}),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Other Columns1",{{"SubCatIndex", "CatIndex"}, {"Sub-Category", "Category"}}),
    #"Appended Query" = Table.Combine({#"Renamed Columns", #"CatIndex"}),
    #"Sorted Rows" = Table.Sort(#"Appended Query",{{"CatIndex", Order.Ascending}})
in
    #"Sorted Rows"

 

which gets you 

structure.JPG

 Create an active relationship between Matrix Category and the orginal table Category. Create an inactive relationship between Matrix Category and the original table SubCategory.

model.JPG

Then these measures:

 

Sum Value = SUM(OrigTable[Amount])
Amount =
VAR SubCat =
    CALCULATE (
        [Sum Value],
        USERELATIONSHIP ( 'Matrix Structure'[Category], OrigTable[Sub-Category] )
    )
RETURN
    IF (
        ISINSCOPE ( 'Matrix Structure'[Category] ),
        [Sum Value] + SubCat,
        "Total "
            & FORMAT ( DIVIDE ( [Sum Value] + SubCat, 2 ), "#,##0" )
    )

 

Create a table visual with the field from the matrix table & the [Amount] measure, add conditional formatting and you get:

Table.JPG

 

Result.JPG

 

Slicer.gif

 I've attached the sample PBIX file





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

7 REPLIES 7
PaulDBrown
Community Champion
Community Champion

Well this isn't perfect, but it's the closest I have come.

1) In Power Query, create the layout of the matrix using:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("fdCxCoAwDATQf8ncweYi6OwnOJYiFcRREB38e6GDFMI5JnkcR1ISlSBTubb9OJ+4zPf6De1BckgCRtXRnlE4OjYbZQW00oFRdTR2zOI3FqwBKjVG1VEwCkcjo+Zo+y1jXU1yfgE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Amount = _t, #"Sub-Category" = _t, Category = _t]),
    OrignalTable = Table.TransformColumnTypes(Source,{{"Amount", Int64.Type}, {"Sub-Category", type text}, {"Category", type text}}),
    #"Removed Other Columns" = Table.SelectColumns(OrignalTable,{"Category"}),
    #"Removed Duplicates" = Table.Distinct(#"Removed Other Columns"),
    #"Added Index" = Table.AddIndexColumn(#"Removed Duplicates", "Index", 1, 1, Int64.Type),
    CatIndex = Table.RenameColumns(#"Added Index",{{"Index", "CatIndex"}}),
    #"Merged Queries" = Table.NestedJoin(CatIndex, {"Category"}, OrignalTable, {"Category"}, "CatIndex.1", JoinKind.LeftOuter),
    #"Expanded CatIndex.1" = Table.ExpandTableColumn(#"Merged Queries", "CatIndex.1", {"Sub-Category"}, {"Sub-Category"}),
    #"Added Index1" = Table.AddIndexColumn(#"Expanded CatIndex.1", "Index", 1, 1, Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Added Index1", "Custom", each [CatIndex] + [Index]/1000),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Index"}),
    SubCatIndex = Table.RenameColumns(#"Removed Columns",{{"Custom", "SubCatIndex"}}),
    #"Removed Other Columns1" = Table.SelectColumns(SubCatIndex,{"Sub-Category", "SubCatIndex"}),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Other Columns1",{{"SubCatIndex", "CatIndex"}, {"Sub-Category", "Category"}}),
    #"Appended Query" = Table.Combine({#"Renamed Columns", #"CatIndex"}),
    #"Sorted Rows" = Table.Sort(#"Appended Query",{{"CatIndex", Order.Ascending}})
in
    #"Sorted Rows"

 

which gets you 

structure.JPG

 Create an active relationship between Matrix Category and the orginal table Category. Create an inactive relationship between Matrix Category and the original table SubCategory.

model.JPG

Then these measures:

 

Sum Value = SUM(OrigTable[Amount])
Amount =
VAR SubCat =
    CALCULATE (
        [Sum Value],
        USERELATIONSHIP ( 'Matrix Structure'[Category], OrigTable[Sub-Category] )
    )
RETURN
    IF (
        ISINSCOPE ( 'Matrix Structure'[Category] ),
        [Sum Value] + SubCat,
        "Total "
            & FORMAT ( DIVIDE ( [Sum Value] + SubCat, 2 ), "#,##0" )
    )

 

Create a table visual with the field from the matrix table & the [Amount] measure, add conditional formatting and you get:

Table.JPG

 

Result.JPG

 

Slicer.gif

 I've attached the sample PBIX file





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Wow! thank you very much! I'm new to power bi so I'll try to figure out each step:) where can I see the code of the power query in the pbix file? Thanks again

You access Power Query through the option "Transform data" in the ribbon

PQ1.gif

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






pbiuser1234
Helper I
Helper I

 

Hi

To the right it's how the data is set in the table,

To the left is how I want to show it - Exactly how it's shown in a matrix, only right to left. 

Thank you

 

Capture.JPG

 

Hi  @pbiuser1234 ,

 

Put category and subcategory to the Rows field and you will see:

vkellymsft_0-1632995839004.png

Check my .pbix  file attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my reply as a solution!

Hi,

I need the "amount" column on the left, not right.

Exacty as shown in the example I attached.

Thanks

PaulDBrown
Community Champion
Community Champion

Can you post a depiction of what you are trying to show?





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors