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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

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
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.