cancel
Showing results 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.

Frequent Visitor

## 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:
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
Community Support

Try the following formula which gets the cumulative value correctly.

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

Best Regards,

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

3 REPLIES 3
Community Support

Try the following formula which gets the cumulative value correctly.

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

Best Regards,

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

Frequent Visitor

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.

Super User

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.

Announcements

#### 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

#### Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

#### Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors