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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Regular Visitor

SUMX inexplicably produces different results in two measures

Dear all


I am experiencing that a piece of DAX-code does what it's supposed to in one measure, but if the same piece of code is inserted in another (slightly more complicatied) measure it does not.


I am working on a live connection to my company's cube.


I am using my measures in a matrix visualisation with three dimensions in the rows (two of them are "projekt" and "aktivitet").


My "Measure 1" works just fine: It calculates the "totals" in the matrix visualisation as the sum of only the positive numbers (which is what I'm trying to achieve). 

Measure 1 = IF(HASONEVALUE(DimProjektAktivitet[AktivitetNr]), 
                   IF([BudgetDiff]<0,BLANK(), BudgetDiff]),
                   SUMX(VALUES(DimProjektAktivitet[AktivitetNr]), IF([BudgetDiff]<0,BLANK(),[BudgetDiff])

Unfortunately I need my measure to do a bit more than that - but still calculate the totals in the same manner.


My "Measure 2" is as follows, where "Measure 1" is now a part of the RETURN-statement. The essential part related to my question is the SUMX(...) part of the code. 


Measure 2 = 
VAR _Budget =
        FILTER(DimSagsPostJunk, DimSagsPostJunk[LinjeType] = "Budget"),
        FILTER(DimSagsPostJunk,DimSagsPostJunk[ArtskontoRessource] IN { "Finans", "Ressource" }),
        FILTER(FactProjektRolle,FactProjektRolle[UserPrincipalName] = [KubeInformationCalcEffectiveUsername])
VAR _Actual= 
        FILTER(DimSagsPostJunk, DimSagsPostJunk[LinjeType] = "Realiseret"),
        FILTER(DimSagsPostJunk, DimSagsPostJunk[ArtskontoRessource] IN {"Finans", "Ressource"}),
        FILTER(FactProjektRolle,FactProjektRolle[UserPrincipalName] = [KubeInformationCalcEffectiveUsername]),
VAR _BudgetDiff = _Budget - _Actual

            IF(_Budget < 0, _BudgetDiff,
                  IF(_BudgetDiff > 0, _BudgetDiff, BLANK()
            SUMX(VALUES(DimProjektAktivitet[AktivitetNr]), IF(_Budget < 0, _BudgetDiff, 
                                                                  IF(_BudgetDiff > 0,_BudgetDiff,BLANK())


The two measures are working just fine, except the fact that "Measure 2" calculates the totals in a different manner than "Measure 1" does: In "Measure 2" the totals become way too large, as if the SUMX()-part has "forgotten" in which context it is.


I sincerely hope that somebody can tell me what I did wrong 🙂

Community Support
Community Support

Hi, @Email60 ;

sumx() Sometimes you write vs two measures and the result of merging one measure is different, mainly due to context, which is normal, you can use the formula that meets your needs.
Secondly, if it doesn't solve your problem, can you share the data and hope to output the results? I can't reproduce your formula above.

Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-yalanwu-msft 


I greatly appreciate your attempt to help 🙂


I have to use my "Measure 2", and am trying to figure out how to get the SUMX()-part of the code to act as expected (as in my simpler "Measure 1"). I understand that it's probably not easy to answer as I can't (at the moment) post my data 😞


Is it possible that the approach by declaring variables (as in "Measure 2") affects the SUMX-calculation (as compared to just referering to tables in my data, as in "Measure 1")? 


Best regards

Helpful resources

Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.