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
Peppearson
Helper I
Helper I

Adding Custom Row to Matrix Table

Hi,

I'm looking to add some custom rows to a matrix table.

Currently I have been able to produce my data in the following format;

Peppearson_0-1669722106162.png

However I would like to add a custom calculated row which is ratio of the category subtotals.

Peppearson_1-1669722129641.png

However I would like to add a custom calculated row which is ratio of the category subtotals.

 

Data Model

I have a sales table and a returns table which are both connected to a lookup and calendar table.

Peppearson_2-1669722179887.png

Any help would be appreciated.

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

Hi @Peppearson ,

 

The data in row field in matrix should be loaded in data model, so "Components/Bikes"/"Accessories/Clothing" should be in a column. Here I suggest you to add a Flag column like [Compare Part] column in your table.

Compare Part = 
IF('Table'[Category] in {"Bikes","Components"},"Components/Bikes","Accessories/Clothing")

RicoZhou_0-1669789525168.png

Measure:

M_Sales = 
IF (
    ISINSCOPE ( 'Table'[Subcategory] ),
    CALCULATE ( SUM ( 'Table'[Sales] ) ),
    IF (
        ISINSCOPE ( 'Table'[Category] ),
        CALCULATE ( SUM ( 'Table'[Sales] ) ),
        IF (
            ISINSCOPE ( 'Table'[Compare Part] ),
            SWITCH (
                SELECTEDVALUE ( 'Table'[Compare Part] ),
                "Components/Bikes",
                    DIVIDE (
                        CALCULATE ( SUM ( 'Table'[Sales] ), 'Table'[Category] = "Components" ),
                        CALCULATE ( SUM ( 'Table'[Sales] ), 'Table'[Category] = "Bikes" )
                    ),
                "Accessories/Clothing",
                    DIVIDE (
                        CALCULATE ( SUM ( 'Table'[Sales] ), 'Table'[Category] = "Accessories" ),
                        CALCULATE ( SUM ( 'Table'[Sales] ), 'Table'[Category] = "Clothing" )
                    )
            )
        )
    )
)

Result is as below.

RicoZhou_1-1669789659567.png

 

Best Regards,
Rico Zhou

 

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-rzhou-msft
Community Support
Community Support

Hi @Peppearson ,

 

The data in row field in matrix should be loaded in data model, so "Components/Bikes"/"Accessories/Clothing" should be in a column. Here I suggest you to add a Flag column like [Compare Part] column in your table.

Compare Part = 
IF('Table'[Category] in {"Bikes","Components"},"Components/Bikes","Accessories/Clothing")

RicoZhou_0-1669789525168.png

Measure:

M_Sales = 
IF (
    ISINSCOPE ( 'Table'[Subcategory] ),
    CALCULATE ( SUM ( 'Table'[Sales] ) ),
    IF (
        ISINSCOPE ( 'Table'[Category] ),
        CALCULATE ( SUM ( 'Table'[Sales] ) ),
        IF (
            ISINSCOPE ( 'Table'[Compare Part] ),
            SWITCH (
                SELECTEDVALUE ( 'Table'[Compare Part] ),
                "Components/Bikes",
                    DIVIDE (
                        CALCULATE ( SUM ( 'Table'[Sales] ), 'Table'[Category] = "Components" ),
                        CALCULATE ( SUM ( 'Table'[Sales] ), 'Table'[Category] = "Bikes" )
                    ),
                "Accessories/Clothing",
                    DIVIDE (
                        CALCULATE ( SUM ( 'Table'[Sales] ), 'Table'[Category] = "Accessories" ),
                        CALCULATE ( SUM ( 'Table'[Sales] ), 'Table'[Category] = "Clothing" )
                    )
            )
        )
    )
)

Result is as below.

RicoZhou_1-1669789659567.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

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.