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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
o59393
Post Prodigy
Post Prodigy

SUMX not returning the actual sum

Hi all,

I have a matrix with the following rows:

1. Facet

2. Tier 1: Process

3. Tier 2: Activity

 

o59393_0-1714325802065.png

 

 

The dax measure called ‘count if’ is correctly allocating 1 when the % is >=1% and 0 when below.

The issue I am facing is that the Tier 1 process row is not summing the 1’ correctly. Instead of 14 value (is summing the total rows of tier 2 activity) it should have a value of 1.

The dax measure is:

 

Count IF = 



var _x = 

SUMX(

    SUMMARIZE(

        Template,

        Template[Merged],

        Template[Hours by Year]

        ),       

        Template[Hours by Year])



var _y = 

        CALCULATE(

    [Non Duplicate Hours Process/Activity Numerator],

        ALLEXCEPT(

            Template,

            Template[Function],

            Template[Area],

            Template[Name]))

var _z = 



DIVIDE(_x,_y)



RETURN



    SUMX(

        DISTINCT(Template[Merged.4]),    

    IF(_z>=0.01,1,0)

    )

 

I guess the issue I have is with the last paragraph with the sumx.

 

Therefore my question is how can I get the sum of the 1’s and have the correct value on the tier 1 process row?

 

Template[Merged.4] is the combination of the columns: [Area], [Function], [#"Tier 1: Process Facet"], [#"Tier 2: Activity Facet"]

 

Thanks. 

 

 

5 REPLIES 5
o59393
Post Prodigy
Post Prodigy

Hi @jdbuchanan71 

 

Closer but still incorrect result of the total. Should be a 2 and it's returning the total number of activities for infrastructure capabilities:

o59393_0-1714346978172.png

 

Thanks

Greg_Deckler
Super User
Super User

@o59393 First, 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


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
jdbuchanan71
Super User
Super User

I wonder if you are having problems because of variables calculating outide the context of the last SUMX iterator.  Does it return the correct result if you try it like this?

Count IF =
SUMX (
    DISTINCT ( Template[Merged.4] ),
    IF (
        (
            VAR _x =
                SUMX (
                    SUMMARIZE ( Template, Template[Merged], Template[Hours by Year] ),
                    Template[Hours by Year]
                )
            VAR _y =
                CALCULATE (
                    [Non Duplicate Hours Process/Activity Numerator],
                    ALLEXCEPT ( Template, Template[Function], Template[Area], Template[Name] )
                )
            VAR _z =
                DIVIDE ( _x, _y )
            RETURN
                _z
        ) >= 0.01,
        1,
        0
    )
)

Hi @jdbuchanan71 

 

If this helps see attached the pbix.

 

The dax measure called count if, is returning 8 instead of 2:

o59393_0-1714349415713.png

 

 

COUNT_IF.pbix

 

Thanks.

Does this measure return the result you are looking for?

SUMX Test = SUMX ( VALUES ( Template[Tier 2: Activity Facet] ), [Count IF] )

jdbuchanan71_0-1714363692704.png

 

Helpful resources

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