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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! 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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.