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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply

Caclulating a cusomter count - help!

I'm new to this code writing....  I'm trying to sum the number of unique customer codes that enter in our stores.  I am coming up with a total by location but the region totals do not sum the stores.  I'm at a loss...

 

Customer = DISTINCTCOUNT((CTMasterTemplate[GersCustomerCode]))  
 
The result is this:
Livia_Hernandez_0-1707415654760.png
When I add the stores independently it should equal the 1663.  Perhaps the same customer entered into a diff store?  I just want the numbers to add up.  I tried a couple different things with no luck.  😞
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Livia_Hernandez ,

 

Try the following formula which gets the cumulative value correctly.

M1 = DISTINCTCOUNT('Table'[Customer])
M2 =
SUMX (
    VALUES ( 'Table'[Product] ),
    CALCULATE ( DISTINCTCOUNT ( 'Table'[Customer] ) )
)

vkongfanfmsft_0-1708325564652.png

vkongfanfmsft_1-1708325576293.png

 

Best Regards,
Adamk Kong

 

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

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @Livia_Hernandez ,

 

Try the following formula which gets the cumulative value correctly.

M1 = DISTINCTCOUNT('Table'[Customer])
M2 =
SUMX (
    VALUES ( 'Table'[Product] ),
    CALCULATE ( DISTINCTCOUNT ( 'Table'[Customer] ) )
)

vkongfanfmsft_0-1708325564652.png

vkongfanfmsft_1-1708325576293.png

 

Best Regards,
Adamk Kong

 

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

Hi @gmsamborn -  I defintitely thought of that too.  I was just trying to see how I could other than manually make the summs just count the stores.  I tried group by with no luck.  Just checking if I was doing something wrong or missing some sort of logic.

 Thank you for replying!

 

gmsamborn
Super User
Super User

Hi @Livia_Hernandez 

 

Is it possible that a customer can be related to more than 1 StoreCode? 

 

In a case like that, each StoreCode would count that customer but that customer would only be counted once in the total.



Proud to be a Super User!

daxformatter.com makes life EASIER!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

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.