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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Kefalin
Regular Visitor

Incorrect Total in matrix visual

Dear Community, 

I have issue with this DAX measure - see below. 
It is not returning correct average in % for Total in matrix visual.
Each QTR is returning correct %, but Total not. Used INSCOPE / NOT INSCOPE function in order to get results for total as well, however average is not OK. In DAX measure i highligthed by red most important parts which are responsible for average calculation. 

If anyone could help i would not jump from the window at least 😄 

Kefalin_1-1723476859784.png

 

 

 

SA FORECAST GAP % Quarters =
VAR CURRENT_YEAR = YEAR(TODAY())
VAR Budget = CALCULATE([AP $k measure], FILTER(ALL(AOP[Cycle]), AOP[Cycle] = CURRENT_YEAR & "-00"))
VAR Mar = CALCULATE([AP $k measure], FILTER(ALL(AOP[Cycle]), AOP[Cycle] = CURRENT_YEAR & "-03"))
VAR Jun = CALCULATE([AP $k measure], FILTER(ALL(AOP[Cycle]), AOP[Cycle] = CURRENT_YEAR & "-06"))
VAR Sep = CALCULATE([AP $k measure], FILTER(ALL(AOP[Cycle]), AOP[Cycle] = CURRENT_YEAR & "-09"))
VAR Dec = CALCULATE([AP $k measure], FILTER(ALL(AOP[Cycle]), AOP[Cycle] = CURRENT_YEAR & "-12"))

VAR Q1 = (Mar - Budget) / Budget)
VAR Q2 = (Jun - Mar) / Mar)
VAR Q3 = (Sep - Jun) / Jun)
VAR Q4 = (Dec - Sep) / Sep)

VAR ValidQuarters =
    FILTER(
        {Q1, Q2, Q3, Q4},
        NOT(ISBLANK([Value]))
    )

VAR QuarterlyAverage =
    IF(
        COUNTROWS(ValidQuarters) = 0,
        BLANK(),
        AVERAGEX(ValidQuarters, [Value])
    )

VAR TotalAdjustment =
    IF(
        ISINSCOPE(EXPECTED_ORDER_DATE[DATE].[Quarter]),
        BLANK(),
        QuarterlyAverage
    )

VAR X =
    SWITCH(
        TRUE(),
        ISINSCOPE(EXPECTED_ORDER_DATE[DATE].[Quarter]),
            SWITCH(
                SELECTEDVALUE(EXPECTED_ORDER_DATE[DATE].[Quarter]),
                "Qtr 1", Q1,
                "Qtr 2", Q2,
                "Qtr 3", Q3,
                "Qtr 4", Q4,
                BLANK()
            ),
        TotalAdjustment
    )

RETURN X
1 REPLY 1
Greg_Deckler
Community Champion
Community Champion

@Kefalin 

First, please vote for the sticker: https://bit.ly/3WX9FeE

Second, please vote for this idea: https://ideas.powerbi.com/ideas/idea/?ideaid=082203f1-594f-4ba7-ac87-bb91096c742e

This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907

Also: https://youtu.be/uXRriTN0cfY
And: https://youtu.be/n4TYhF2ARe8



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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