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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
mclawler
Helper II
Helper II

Totals not calculating correctly using SumX

Hey there, love this community as it's been a huge help along my career path.  I have a scenario where only these 2 totals are not calculating correctly, and I've used SumX in the past with success but it doesn't appear to be working this time.  Please advise. 

 

Neither of these DAX metrics are calculating the total correctly:

 

MemberNumberDISTINCTCOUNT =
SUMX (
    VALUES ( Heloc3MonthAdvances[TransactionDateMonth] ),
    DISTINCTCOUNT ( Heloc3MonthAdvances[MemberNumber] ))
 
MemberNumberYTD DISTINCTCOUNT =
SUMX (
    VALUES ( Heloc3MonthAdvances[TransactionDate].[Month]),
TOTALYTD(
    DISTINCTCOUNT('Heloc3MonthAdvances'[MemberNumber]),DateTable[Date]))
 
mclawler_0-1707238030636.png

 

 
4 REPLIES 4
Greg_Deckler
Super User
Super User

@mclawler Try replacing VALUES with DISTINCT as you might be getting a blank row returned that has a value being included in your total. 

 

Also, You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000

Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...


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

Hi Greg, I tried replacing VALUES with DISTINCT with no success.  I have generated other source reports and the Total should be 469, somehow the Total row is not capturing everything in the column above it (468)?

 

To make things even more confusing, these 3 DAX are working correctly with the same data table and same rows as above:

 

MemberNumberPrevious_Month_DISTINCTCOUNT = CALCULATE(DISTINCTCOUNT('Heloc3MonthAdvances'[MemberNumber]),DATEADD('DateTable'[Date],-1,MONTH))
 
mclawler_0-1707240238970.png

 

MemberNumberPrevious_Year_DISTINCTCOUNT = SUMX (
    VALUES ( Heloc3MonthAdvances[TransactionDate].[Month]),CALCULATE(DISTINCTCOUNT('Heloc3MonthAdvances'[MemberNumber]),DATEADD('DateTable'[Date],-1,YEAR)))

mclawler_1-1707240276468.png

MemberNumberYoYTD DISTINCTCOUNT = SUMX (
    VALUES ( Heloc3MonthAdvances[TransactionDate].[Month]),
    TOTALYTD(
        DISTINCTCOUNT('Heloc3MonthAdvances'[MemberNumber]),
    DATEADD('DateTable'[Date],-1,YEAR)))
mclawler_2-1707240344985.png

 

@mclawler Maybe try swapping out your SUMX for ADDCOLUMNS and then return the table using TOCSV to see what is actually going on.


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

Ok, I really did some digging on the data and turns out I was mistaken from the getgo but I still have an issue.  

 

The correct Total is 468.  The Correct Existing HELOC row is 433.  The incorrect New HELOC row in reality should be 35 instead of 36.  So my Row is showing an additional Disctinct Count.  Would it be counting the Column Header maybe?  I'm not sure where it's picking up the additional 1 item.  Sorry for the previous confusion

mclawler_0-1707263368214.png

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.

Top Solution Authors