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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
KenLucaaaaaa
Frequent Visitor

Total Sum with SumX not correct - what to do?

Hi all,

 

I would appreciate your help with the following issue:

I'm trying to calculate how many conditions (2) per month are fulfilled by each customer. That is working fine.

But as you can see the sum is always the same (just 2x the amount of customers, 3653).

What I need is, that in the sum row it's only summing of the values from the corresponding colum (so for example: 2+0+0+1+2+1 ...........)    and not what seems to happen now (2+2+2+2+2 .......)

What am I doing wrong?

 

KenLucaaaaaa_0-1699005950607.png

 

NPD Bonus =
Var NPD1_Ums = CALCULATE(sum(F_PosSalesPurchPriceGer[UmsatzAEP]), DATESINPERIOD(D_Date[Tagesdatum],MAX(D_Date[Tagesdatum]),-7,DAY) ,Filter(D_Products, D_Products[Pzn] in {16507534}))
Var NPD2_Ums = CALCULATE(sum(F_PosSalesPurchPriceGer[UmsatzAEP]), DATESINPERIOD(D_Date[Tagesdatum],MAX(D_Date[Tagesdatum]),-7,DAY) ,Filter(D_Products, D_Products[Pzn] in {16507540}))


Var NPD1 =  if(NPD1_Ums > 0, 1, 0)
Var NPD2 =  if(NPD2_Ums > 0, 1, 0)

return

sumx(D_Kunde, NPD1 + NPD2)
1 REPLY 1
rubayatyasmin
Super User
Super User

Hi, @KenLucaaaaaa 

 

in your code, SUMX is evaluating the sum of NPD1 and NPD2 for each D_Kunde thus resulting 2x numbers for all the customers. 

 

you can modify the code as below, 

 

NPD Bonus =
VAR NPD1_Ums = CALCULATE(
    SUM(F_PosSalesPurchPriceGer[UmsatzAEP]),
    DATESINPERIOD(D_Date[Tagesdatum], MAX(D_Date[Tagesdatum]), -7, DAY),
    Filter(D_Products, D_Products[Pzn] in {16507534})
)

VAR NPD2_Ums = CALCULATE(
    SUM(F_PosSalesPurchPriceGer[UmsatzAEP]),
    DATESINPERIOD(D_Date[Tagesdatum], MAX(D_Date[Tagesdatum]), -7, DAY),
    Filter(D_Products, D_Products[Pzn] in {16507540})
)

VAR TotalNPD = 
    SUMX(
        D_Kunde,
        IF(NPD1_Ums > 0, 1, 0) + IF(NPD2_Ums > 0, 1, 0)
    )

RETURN TotalNPD

 

this should be helpful.


Did I answer your question? Mark my post as a solution!super-user-logo

Proud to be a Super User!


Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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