Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
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 =
CALCULATE(
SUM(FactSagspost[Beloeb]),
FILTER(DimSagsPostJunk, DimSagsPostJunk[LinjeType] = "Budget"),
FILTER(DimSagsPostJunk,DimSagsPostJunk[ArtskontoRessource] IN { "Finans", "Ressource" }),
FILTER(FactProjektRolle,FactProjektRolle[UserPrincipalName] = [KubeInformationCalcEffectiveUsername])
)
VAR _Actual=
CALCULATE(
SUM(FactSagspost[Beloeb]),
FILTER(DimSagsPostJunk, DimSagsPostJunk[LinjeType] = "Realiseret"),
FILTER(DimSagsPostJunk, DimSagsPostJunk[ArtskontoRessource] IN {"Finans", "Ressource"}),
FILTER(FactProjektRolle,FactProjektRolle[UserPrincipalName] = [KubeInformationCalcEffectiveUsername]),
ALL(DimBudgetnavn)
)
VAR _BudgetDiff = _Budget - _Actual
RETURN
IF(HASONEVALUE(DimProjektAktivitet[AktivitetNr]),
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 🙂
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.
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
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
90 | |
88 | |
83 | |
64 | |
49 |
User | Count |
---|---|
127 | |
108 | |
87 | |
70 | |
66 |