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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.