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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
edwinb
Frequent Visitor

Matrix consecutive stepped data

I have data in an excel file structured like in the table below. My goal is to be able to use the Matrix visual with the +/- icons to expand the code groups A, B, C by the consecutive levels. I've tested breaking the code column into different columns in excel and the query editor. I also tried to setup a heirarchy in Power BI with no luck. Any suggestions on the cleanest way to accomplish this? 

Thanks!

 

CodeDescriptionLevel
ASubstructure1
A10Foundations2
A1010Standard Foundations3
A1010100Footings & Pile Caps4
A1010110Strip Footings5
A1010120Spread Footings5
A1010130Pile Caps5
BShell1
B10Superstructure2
B1010Floor Construction3
B1010100Suspended Basement Floor Construction4
B1010200Upper Floor Framing - Vertical Elements4
B1010210Bearing Walls - CIP5
B1010215Bearing Walls - Block5
CInteriors1
C10Interior Construction2
C1010Partitions3
C1010100Fixed Partitions4
C1010110"Partitions - Brick, Solid"5
C1010115Partitions - Brick Veneer w/ Stud5
1 ACCEPTED SOLUTION
speedramps
Super User
Super User

Hi edwin

 

Please consider this solution and leave kudos:-

 

Add new columns in your query:-

 

    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Code", type text}, {"Description", type text}, {"Level", Int64.Type}}),

    #"Inserted First Characters" = Table.AddColumn(#"Changed Type", "Product group", each Text.Start([Code], 1), type text),

    #"Inserted Text Range" = Table.AddColumn(#"Inserted First Characters", "Product category", each Text.Middle([Code], 1, 2), type text),

    #"Inserted Text Range1" = Table.AddColumn(#"Inserted Text Range", "Product subcat", each Text.Middle([Code], 3, 2), type text),

    #"Renamed Columns" = Table.RenameColumns(#"Inserted Text Range1",{{"Code", "Product code"}})

in

    #"Renamed Columns" 

 

 

Create a hierarchy with:-

 

Product group                   (character 1)

Product category              (character 2-3)

Product subcategory        (character 4-5)

Product code                    (character 1-8)

 

Drag the hierarchy to the matrix and use +/- to expand and collapse each level

 

Click here to download example 

 

 

 

View solution in original post

2 REPLIES 2
speedramps
Super User
Super User

Hi edwin

 

Please consider this solution and leave kudos:-

 

Add new columns in your query:-

 

    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Code", type text}, {"Description", type text}, {"Level", Int64.Type}}),

    #"Inserted First Characters" = Table.AddColumn(#"Changed Type", "Product group", each Text.Start([Code], 1), type text),

    #"Inserted Text Range" = Table.AddColumn(#"Inserted First Characters", "Product category", each Text.Middle([Code], 1, 2), type text),

    #"Inserted Text Range1" = Table.AddColumn(#"Inserted Text Range", "Product subcat", each Text.Middle([Code], 3, 2), type text),

    #"Renamed Columns" = Table.RenameColumns(#"Inserted Text Range1",{{"Code", "Product code"}})

in

    #"Renamed Columns" 

 

 

Create a hierarchy with:-

 

Product group                   (character 1)

Product category              (character 2-3)

Product subcategory        (character 4-5)

Product code                    (character 1-8)

 

Drag the hierarchy to the matrix and use +/- to expand and collapse each level

 

Click here to download example 

 

 

 

@speedramps 

 

Thank you for the help! 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.