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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Zack92
Helper III
Helper III

Help Needed – Grand Total Not Showing in Matrix Table

Hello,

I need a bit of help with getting the Grand Total to show up at the bottom of my Matrix table. I created a custom measure to display the view I need, but for some reason, the total isn’t showing correctly. I couldn’t get it to work. Any help fixing this would be really appreciated! It’ll probably make more sense if you can take a look at my sample file.
image.png

 image.png

Metrics = DATATABLE(
    "Metric", STRING,
    "SortOrder", INTEGER,
    {
        {"Revenue", 1},
        {"Volume", 2},
        {"Gross Profit $", 3},
        {"Gross Margin %", 4}
    }
)
Value = 
SWITCH(
    SELECTEDVALUE(Metrics[Metric]),
    "Revenue", SUM(nl_Sales[ext_price])/1000,
    "Volume", SUM(nl_Sales[inv_qty]),
    "Gross Profit $", SUM(nl_Sales[gp$])/1000,
    "Gross Margin %", If([Gross Profit $]/[Revenue]>1 || [Gross Profit $]/[Revenue]<0,Blank(),[Gross Profit $]/[Revenue]) *100,
    BLANK()
)
YoY % Change = 
VAR CurrentValue = 
    SWITCH(
        TRUE(),
        SELECTEDVALUE(Metrics[Metric]) = "Revenue", [Revenue],
        SELECTEDVALUE(Metrics[Metric]) = "Volume", [Volume],
        SELECTEDVALUE(Metrics[Metric]) = "Gross Profit $", [Gross Profit $],
        SELECTEDVALUE(Metrics[Metric]) = "Gross Margin %", [Gross Margin %],
        BLANK()
    )
    
VAR LastPeriodValue = 
    SWITCH(
        TRUE(),
        ISFILTERED('Date'[Date].[Quarter]) || ISFILTERED('Date'[Date].[Month]),
            CALCULATE(
                SWITCH(
                    TRUE(),
                    SELECTEDVALUE(Metrics[Metric]) = "Revenue", [Revenue],
                    SELECTEDVALUE(Metrics[Metric]) = "Volume", [Volume],
                    SELECTEDVALUE(Metrics[Metric]) = "Gross Profit $", [Gross Profit $],
                    SELECTEDVALUE(Metrics[Metric]) = "Gross Margin %", [Gross Margin %],
                    BLANK()
                ),
                PARALLELPERIOD('Date'[Date], -1, QUARTER)  
            ),
        ISFILTERED('Date'[Date].[Year]), 
            CALCULATE(
                SWITCH(
                    TRUE(),
                    SELECTEDVALUE(Metrics[Metric]) = "Revenue", [Revenue],
                    SELECTEDVALUE(Metrics[Metric]) = "Volume", [Volume],
                    SELECTEDVALUE(Metrics[Metric]) = "Gross Profit $", [Gross Profit $],
                    SELECTEDVALUE(Metrics[Metric]) = "Gross Margin %", [Gross Margin %],
                    BLANK()
                ),
                SAMEPERIODLASTYEAR('Date'[Date]) 
            ),
        BLANK()
    )

RETURN 
    IF(
        ISBLANK(LastPeriodValue),
        BLANK(),  -
        DIVIDE(CurrentValue - LastPeriodValue, LastPeriodValue, 0) * 100  
    )


Sample File 
https://drive.google.com/file/d/1F56ShHxhMJBHTJ25uA8F1ETDysRIzSnf/view?usp=sharing

 

Thanks so much!



1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file whether it solves the issue.

 

Jihwan_Kim_0-1744858243350.png

Selected Metric Value = 
SUMX (
    VALUES ( Metrics[Metric] ),
    CALCULATE (
        SWITCH (
            SELECTEDVALUE ( Metrics[Metric] ),
            "Revenue", SUM ( nl_Sales[ext_price] ) / 1000,
            "Volume", SUM ( nl_Sales[inv_qty] ),
            "Gross Profit $", SUM ( nl_Sales[gp$] ) / 1000,
            "Gross Margin %",
                IF (
                    [Gross Profit $] / [Revenue] > 1
                        || [Gross Profit $] / [Revenue] < 0,
                    BLANK (),
                    [Gross Profit $] / [Revenue]
                ) * 100,
            BLANK ()
        )
    )
)

 

YoY % Change = 
VAR CurrentValue =
    SUMX (
        VALUES ( Metrics[Metric] ),
        CALCULATE (
            SWITCH (
                TRUE (),
                SELECTEDVALUE ( Metrics[Metric] ) = "Revenue", [Revenue],
                SELECTEDVALUE ( Metrics[Metric] ) = "Volume", [Volume],
                SELECTEDVALUE ( Metrics[Metric] ) = "Gross Profit $", [Gross Profit $],
                SELECTEDVALUE ( Metrics[Metric] ) = "Gross Margin %", [Gross Margin %],
                BLANK ()
            )
        )
    )
VAR LastPeriodValue =
    SUMX (
        VALUES ( Metrics[Metric] ),
        CALCULATE (
            SWITCH (
                TRUE (),
                ISFILTERED ( 'Date'[Date].[Quarter] ) || ISFILTERED ( 'Date'[Date].[Month] ),
                    CALCULATE (
                        SWITCH (
                            TRUE (),
                            SELECTEDVALUE ( Metrics[Metric] ) = "Revenue", [Revenue],
                            SELECTEDVALUE ( Metrics[Metric] ) = "Volume", [Volume],
                            SELECTEDVALUE ( Metrics[Metric] ) = "Gross Profit $", [Gross Profit $],
                            SELECTEDVALUE ( Metrics[Metric] ) = "Gross Margin %", [Gross Margin %],
                            BLANK ()
                        ),
                        PARALLELPERIOD ( 'Date'[Date], -1, QUARTER )
                    ),
                ISFILTERED ( 'Date'[Date].[Year] ),
                    CALCULATE (
                        SWITCH (
                            TRUE (),
                            SELECTEDVALUE ( Metrics[Metric] ) = "Revenue", [Revenue],
                            SELECTEDVALUE ( Metrics[Metric] ) = "Volume", [Volume],
                            SELECTEDVALUE ( Metrics[Metric] ) = "Gross Profit $", [Gross Profit $],
                            SELECTEDVALUE ( Metrics[Metric] ) = "Gross Margin %", [Gross Margin %],
                            BLANK ()
                        ),
                        SAMEPERIODLASTYEAR ( 'Date'[Date] )
                    ),
                BLANK ()
            )
        )
    )
RETURN
    IF (
        ISBLANK ( LastPeriodValue ),
        BLANK (),
        - DIVIDE ( CurrentValue - LastPeriodValue, LastPeriodValue, 0 ) * 100
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

2 REPLIES 2
Zack92
Helper III
Helper III

@Jihwan_Kim Thank you so much, that works. What did you do to fix it? Really appreciate your help. 

Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file whether it solves the issue.

 

Jihwan_Kim_0-1744858243350.png

Selected Metric Value = 
SUMX (
    VALUES ( Metrics[Metric] ),
    CALCULATE (
        SWITCH (
            SELECTEDVALUE ( Metrics[Metric] ),
            "Revenue", SUM ( nl_Sales[ext_price] ) / 1000,
            "Volume", SUM ( nl_Sales[inv_qty] ),
            "Gross Profit $", SUM ( nl_Sales[gp$] ) / 1000,
            "Gross Margin %",
                IF (
                    [Gross Profit $] / [Revenue] > 1
                        || [Gross Profit $] / [Revenue] < 0,
                    BLANK (),
                    [Gross Profit $] / [Revenue]
                ) * 100,
            BLANK ()
        )
    )
)

 

YoY % Change = 
VAR CurrentValue =
    SUMX (
        VALUES ( Metrics[Metric] ),
        CALCULATE (
            SWITCH (
                TRUE (),
                SELECTEDVALUE ( Metrics[Metric] ) = "Revenue", [Revenue],
                SELECTEDVALUE ( Metrics[Metric] ) = "Volume", [Volume],
                SELECTEDVALUE ( Metrics[Metric] ) = "Gross Profit $", [Gross Profit $],
                SELECTEDVALUE ( Metrics[Metric] ) = "Gross Margin %", [Gross Margin %],
                BLANK ()
            )
        )
    )
VAR LastPeriodValue =
    SUMX (
        VALUES ( Metrics[Metric] ),
        CALCULATE (
            SWITCH (
                TRUE (),
                ISFILTERED ( 'Date'[Date].[Quarter] ) || ISFILTERED ( 'Date'[Date].[Month] ),
                    CALCULATE (
                        SWITCH (
                            TRUE (),
                            SELECTEDVALUE ( Metrics[Metric] ) = "Revenue", [Revenue],
                            SELECTEDVALUE ( Metrics[Metric] ) = "Volume", [Volume],
                            SELECTEDVALUE ( Metrics[Metric] ) = "Gross Profit $", [Gross Profit $],
                            SELECTEDVALUE ( Metrics[Metric] ) = "Gross Margin %", [Gross Margin %],
                            BLANK ()
                        ),
                        PARALLELPERIOD ( 'Date'[Date], -1, QUARTER )
                    ),
                ISFILTERED ( 'Date'[Date].[Year] ),
                    CALCULATE (
                        SWITCH (
                            TRUE (),
                            SELECTEDVALUE ( Metrics[Metric] ) = "Revenue", [Revenue],
                            SELECTEDVALUE ( Metrics[Metric] ) = "Volume", [Volume],
                            SELECTEDVALUE ( Metrics[Metric] ) = "Gross Profit $", [Gross Profit $],
                            SELECTEDVALUE ( Metrics[Metric] ) = "Gross Margin %", [Gross Margin %],
                            BLANK ()
                        ),
                        SAMEPERIODLASTYEAR ( 'Date'[Date] )
                    ),
                BLANK ()
            )
        )
    )
RETURN
    IF (
        ISBLANK ( LastPeriodValue ),
        BLANK (),
        - DIVIDE ( CurrentValue - LastPeriodValue, LastPeriodValue, 0 ) * 100
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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