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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
tarcisiomu
Regular Visitor

Distinct Count (customer) x Brand x Threshold

Hello guys,

 

I am struggling to find a way to make the following calculation.

 

I need to count the number of active customer per month per each brand, but each brand has a specific threshold. For instance:

Customer 1789 ordered 5 units of Brand X

Customer 9867 ordered 3 units of Brand X

Customer 2341 ordered 30 units of Brand X

Customer 2341 ordered 12 units of Brand Y

Considering the threshold for product X is >=5 and for Y is >=10 I would have two customers for Brand X (1789 and 2341) and one customer for Brand Y (2341).

 

 

I am using this function, but when I put the second condition (brand) it does not work...

 

=CALCULATE
(
DISTINCTCOUNT([Cliente]);
DATESBETWEEN(Tabela1[Data]; "01/01/2015"; "31/12/2015");
Tabela1[Quantidade]>=5
)

 

Any help from the genius out there? 🙂

3 REPLIES 3
Phil_Seamark
Microsoft Employee
Microsoft Employee

Can you please post a small sample set of your data (including column names) and we can try and create a calculated measure for you.


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Hello, Phil

 

This is a piece of the data:

 

Order #DateCustomerBrandQuantity
46966908/02/20171009CRD3
46967810/02/20171009CRD2
46966912/02/20171009CRD-3
47060112/02/20171015JIM1
47060112/02/20171015JIM2
47060112/02/20171015JIM2
47061212/02/20171015CEL9
47061312/02/20171015CEL2
47061212/02/20171015CEL-1
47083314/02/20171061CRD5
47083314/02/20171061FEN9
47083314/02/20171061FEN1
47088714/02/20171262JIM3
47088714/02/20171262JIM2

 

CRD THRESHOLD>=5
JIM THRESHOLD>=5
CEL THRESHOLD>=10
FEN THRESHOLD>=10

 

Considering the threshold for each brand, the final result should be:

2 customers for brand JIM (1015 and 1262)

1 customer for brand CEL (1015)

1 customer for brand CRD (1061) we need to discard the customer 1009 considering the return of 3 units, therefore the final result is 2 no reaching the threshold

1 customer for brand FEN (1061)

 

I hope this helps you to help me 🙂

How does this look?

 

There is an element of hardcoding the rules as you can see.  These would be better kept in a table so you can update.  Unless you know for sure they never change.

 

Add a new table as follows: I assumed the table you provided was called 'Brand'


Summary Table = FILTER( SUMMARIZE( 'Brand', Brand[Brand], Brand[Customer], "Orders",sum(Brand[Quantity]) ), ([Brand] = "JIM" && [Orders]>=5) || ([Brand] = "CRD" && [Orders]>=5) || ([Brand] = "CEL" && [Orders]>=10) || ([Brand] = "FEN" && [Orders]>=10) )

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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