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