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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
veerach
Frequent Visitor

Matrix visual - Regular and Dynamic columns - is this possible?

Hi everyone, 

I have data like this

AreaCompanyProductOrdered QtyActual Qty
AMatrix IncPen4411
AMatrix IncPaper5025
AMatrix IncBook107
AMatrix IncStand1612
ATech CoPen2016
ATech CoPaper3515
BApptechBook155
BApptechStand2510
BApptechBench107
BApptechPen1612
BZ IncPaper2016
BZ IncBook3515
BZ IncCard5025

 

I have a requirement to show the data in this format

       
AreaCompany CountTotal OrderedTotal Actual% Actual/OrderedOrdered PenPaperBookStandBenchCardActual PenPaperBookStandBenchCard
A21758649%66851016  2741712  
B21719053%16205025105012162010725

 

The products are dynamic in nature, I tried to use Matrix visual. Either I can do count, totals and percentage or only products. Can anyone suggest an approach to include both in same visual. (The idea here is user wants to see aggregate values by area, if he wants he can drill down to company level to see the details.)

 

Thanks

Veera

 

1 ACCEPTED SOLUTION
v-kkf-msft
Community Support
Community Support

Hi @veerach ,

 

1. Please unpivot the Ordered Qty and the Actual Qty columns.

vkkfmsft_0-1650264324654.pngvkkfmsft_1-1650264342676.png

 

2. Create the new table: MatrixTable.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WUtJRcs7PLUjMq1Rwzi/NK1GK1QELhuSXJOYo+BelpBalpqAKOiaXlCbmwMRUoXx9uNpYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Category = _t, Product = _t]),
    #"Appended Query" = Table.Combine({Source,Table.SelectColumns(Table,{"Category","Product"})}),
    #"Removed Duplicates" = Table.Distinct(#"Appended Query")
in
    #"Removed Duplicates"

vkkfmsft_3-1650267200892.png

 

3. Create the table: SlicerTable.

 

let
    Source = Table.SelectColumns(Table,"Product"),
    #"Removed Duplicates" = Table.Distinct(Source),
    #"Added Custom" = Table.AddColumn(#"Removed Duplicates", "MatrixColumns", each Table.Distinct( Table.SelectColumns(MatrixTable,"Product") )),
    #"Expanded MatrixColumns" = Table.ExpandTableColumn(#"Added Custom", "MatrixColumns", {"Product"}, {"MatrixColumns"}),
    #"Filtered Rows" = Table.SelectRows(#"Expanded MatrixColumns", each ([MatrixColumns] = "% Actual/Ordered" or [MatrixColumns] = "Company Count" or [MatrixColumns] = "Total Actual" or [MatrixColumns] = "Total Ordered" or [MatrixColumns] = [Product]))
in
    #"Filtered Rows"

vkkfmsft_2-1650267170197.png

 

4. Create the relationship.

 

vkkfmsft_4-1650267390896.png

 

5. Create the measure.

 

Measure = 
VAR filtertab =
    TREATAS ( VALUES ( MatrixTable[Product] ), 'Table'[Product] )
RETURN
    SWITCH (
        MAX ( MatrixTable[Category] ),
        "Ordered Qty", CALCULATE ( [Total Ordered], filtertab ),
        "Actual Qty", CALCULATE ( [Total Actual], filtertab ),
        SWITCH (
            MAX ( MatrixTable[Product] ),
            "Company Count", [Company Count],
            "Total Ordered", [Total Ordered],
            "Total Actual", [Total Actual],
            "% Actual/Ordered", FORMAT ( [% Actual/Ordered], "Percent" )
        )
    )

vkkfmsft_6-1650267463154.png

vkkfmsft_5-1650267446541.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

1 REPLY 1
v-kkf-msft
Community Support
Community Support

Hi @veerach ,

 

1. Please unpivot the Ordered Qty and the Actual Qty columns.

vkkfmsft_0-1650264324654.pngvkkfmsft_1-1650264342676.png

 

2. Create the new table: MatrixTable.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WUtJRcs7PLUjMq1Rwzi/NK1GK1QELhuSXJOYo+BelpBalpqAKOiaXlCbmwMRUoXx9uNpYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Category = _t, Product = _t]),
    #"Appended Query" = Table.Combine({Source,Table.SelectColumns(Table,{"Category","Product"})}),
    #"Removed Duplicates" = Table.Distinct(#"Appended Query")
in
    #"Removed Duplicates"

vkkfmsft_3-1650267200892.png

 

3. Create the table: SlicerTable.

 

let
    Source = Table.SelectColumns(Table,"Product"),
    #"Removed Duplicates" = Table.Distinct(Source),
    #"Added Custom" = Table.AddColumn(#"Removed Duplicates", "MatrixColumns", each Table.Distinct( Table.SelectColumns(MatrixTable,"Product") )),
    #"Expanded MatrixColumns" = Table.ExpandTableColumn(#"Added Custom", "MatrixColumns", {"Product"}, {"MatrixColumns"}),
    #"Filtered Rows" = Table.SelectRows(#"Expanded MatrixColumns", each ([MatrixColumns] = "% Actual/Ordered" or [MatrixColumns] = "Company Count" or [MatrixColumns] = "Total Actual" or [MatrixColumns] = "Total Ordered" or [MatrixColumns] = [Product]))
in
    #"Filtered Rows"

vkkfmsft_2-1650267170197.png

 

4. Create the relationship.

 

vkkfmsft_4-1650267390896.png

 

5. Create the measure.

 

Measure = 
VAR filtertab =
    TREATAS ( VALUES ( MatrixTable[Product] ), 'Table'[Product] )
RETURN
    SWITCH (
        MAX ( MatrixTable[Category] ),
        "Ordered Qty", CALCULATE ( [Total Ordered], filtertab ),
        "Actual Qty", CALCULATE ( [Total Actual], filtertab ),
        SWITCH (
            MAX ( MatrixTable[Product] ),
            "Company Count", [Company Count],
            "Total Ordered", [Total Ordered],
            "Total Actual", [Total Actual],
            "% Actual/Ordered", FORMAT ( [% Actual/Ordered], "Percent" )
        )
    )

vkkfmsft_6-1650267463154.png

vkkfmsft_5-1650267446541.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors