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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
CuriousGuy001
Helper I
Helper I

Creating Cateogry Product and Multiple Sub-Categroies

Hi Everyone,

 

I have been trying to figure out a way to create a Matrix vizualizations for a report, I have the on the column for Sales rep. and row for product category and what I want is to insert ONE measure that contain 4 subcategory and within the 4 subcategories can expand into more detail of items that have been sold by each Sales rep. The values will the Total count that the sales rep sold.

 

The problem that I get whenever I drag 4 data (each column) into the rows, it creates a subcategory of a subcategory of a subcategory, so I was wondering if there a way to fix this in a matrix.

 

Product Category.png 

1 ACCEPTED SOLUTION
AntrikshSharma
Super User
Super User

@CuriousGuy001 The right way to store this type of data is to have 3 columns Category > Subcategory >  Name by unpivoting other columns

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wcs3JLElVcCrNS8lJVdJRciwoANNORfnJ+TmZQJZzYnFxYlkikOWWWZyhFKsD0xOQk1iSmVeai9DsX5SYlw5ihOTnJpbkpxaDDEpNLQHRzkWJScVKsbEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Category = _t, Fruits = _t, Vegetables = _t, Roots = _t, Seafood = _t]),
    ChangedType = Table.TransformColumnTypes ( 
        Source,
        {
            {"Category", type text}, 
            {"Fruits", type text}, 
            {"Vegetables", type text}, 
            {"Roots", type text}, 
            {"Seafood", type text}
        }
    ),
    UnpivotedOtherColumns = Table.UnpivotOtherColumns (
        ChangedType, 
        {"Category"}, 
        "Subcategory", "Name"
    )
in
    UnpivotedOtherColumns

use the above code to generate the table.

 

Then you can create a Matrix like the following one and you won't have repeated unexisting combinations

 

AntrikshSharma_0-1716396125505.png

 

 

View solution in original post

3 REPLIES 3
AntrikshSharma
Super User
Super User

@CuriousGuy001 The right way to store this type of data is to have 3 columns Category > Subcategory >  Name by unpivoting other columns

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wcs3JLElVcCrNS8lJVdJRciwoANNORfnJ+TmZQJZzYnFxYlkikOWWWZyhFKsD0xOQk1iSmVeai9DsX5SYlw5ihOTnJpbkpxaDDEpNLQHRzkWJScVKsbEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Category = _t, Fruits = _t, Vegetables = _t, Roots = _t, Seafood = _t]),
    ChangedType = Table.TransformColumnTypes ( 
        Source,
        {
            {"Category", type text}, 
            {"Fruits", type text}, 
            {"Vegetables", type text}, 
            {"Roots", type text}, 
            {"Seafood", type text}
        }
    ),
    UnpivotedOtherColumns = Table.UnpivotOtherColumns (
        ChangedType, 
        {"Category"}, 
        "Subcategory", "Name"
    )
in
    UnpivotedOtherColumns

use the above code to generate the table.

 

Then you can create a Matrix like the following one and you won't have repeated unexisting combinations

 

AntrikshSharma_0-1716396125505.png

 

 

some_bih
Community Champion
Community Champion

Hi @CuriousGuy001 matrix usually reflect what is your model (relationships and measures).

Check / change your model or measure definition to see how it affects matrix results.

Without model and simple data it is hard to spot your issue.

 





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

Proud to be a Super User!






Hi there,

 

Thank you for your comment! I will post a diagram to what I am looking for. Let me know if that help to understand my questions.Screenshot 2024-05-22 113916.png

Helpful resources

Announcements
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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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