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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
mclawler
Helper III
Helper III

DistinctCount with individual Rows Summing incorrectly

**Moderators, please remove the previous thread I created titled "Totals not calculating correctly using SumX" as I have dug much deeper into this issue and realized the actual root of the problem.**

 

I have concluded that my Matrix Table is calculating the correct amount of DistinctCount(MemberNumber) Total.  However, there is 1 MemberNumber that exists for both results "Existing" & "New" within the calculcated column.  Therefore, when my DAX is using DistinctCount for the entire column it gets the correct result of 468.  But, when it is using DistinctCount for each result "Existing" & "New" as separate rows, it's not seeing that overlapping MemberNumber and counts it as an additional DisctinctCount within the "New" row.  Please advise how to make each Row's filter/isolation take into account the entire Column's data.  

 

Current DAX:

MemberNumberDISTINCTCOUNT =
SUMX( VALUES(Heloc3MonthAdvances[TransactionDateMonth]),
   DISTINCTCOUNT ( Heloc3MonthAdvances[MemberNumber] ))

 

The end result should read:

Existing = 433

New = 35

Total = 468

 

This is the current visual:

mclawler_0-1707763128864.png

Thank you!! 

 

 

5 REPLIES 5
Anonymous
Not applicable

Hi @mclawler 

 

@lbendlin  Thank you very much for sharing!

 

This is a very suitable way, here I provide some specific code. You can try the following code:

MemberNumberDISTINCTCOUNT =
SUMX (
    VALUES ( Heloc3MonthAdvances[TransactionDateMonth] ),
    DISTINCTCOUNT ( Heloc3MonthAdvances[MemberNumber] )
)

 

MemberNumberDISTINCTCOUNT_Existing =
CALCULATE (
    [MemberNumberDISTINCTCOUNT],
    Heloc3MonthAdvances[Result] = "Existing"
)

 

MemberNumberDISTINCTCOUNT_New =
CALCULATE (
    [MemberNumberDISTINCTCOUNT],
    Heloc3MonthAdvances[Result] = "New",
    EXCEPT (
        VALUES ( Heloc3MonthAdvances[MemberNumber] ),
        CALCULATETABLE (
            VALUES ( Heloc3MonthAdvances[MemberNumber] ),
            Heloc3MonthAdvances[Result] = "Existing"
        )
    )
)

 

This should give you the results you want, which is 433 for "Existing" and 35 for "New".

 

EXCEPT function (DAX) - DAX | Microsoft Learn

 

Regards,

Nono Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you for the reply I think you're on the right track but it's giving me blanks.  Currently I use a calculated column to generate the rows for Existing/New:

 

Existing/New = IF(Heloc3MonthAdvances[OpenDateMonth] < Heloc3MonthAdvances[TransactionDateMonth],"Existing HELOC","New HELOC")

 

mclawler_0-1707841336558.png

 

Any idea how to modify your code to adapt to my rows?  I have to keep my rows becuase in the same table I use other measures for $ Sum and YoY, MoM, etc... Thank you so much for your help! 

 

I tried these with no success:

MemberNumberDISTINCTCOUNT_Existing =
CALCULATE (
    [MemberNumberDISTINCTCOUNT],
    Heloc3MonthAdvances[Existing/New] = "Existing"
)
 
MemberNumberDISTINCTCOUNT_New =
CALCULATE (
    [MemberNumberDISTINCTCOUNT],
    Heloc3MonthAdvances[Existing/New] = "New",
    EXCEPT (
        VALUES ( Heloc3MonthAdvances[MemberNumber] ),
        CALCULATETABLE (
            VALUES ( Heloc3MonthAdvances[MemberNumber] ),
            Heloc3MonthAdvances[Existing/New] = "Existing"
        )
    )
)
lbendlin
Super User
Super User

Use EXCEPT to weed out the extra member in New.

Please see my reponse above, after reading what EXCEPT can do I believe you're right but can't figure out the proper code.  Please advise, and thank you for your help! 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.