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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
KyleTaylor
Advocate I
Advocate I

DAX measure to count customers with multiple sizes in each order per day

Hi,

 

Please help! I need a DAX measure to count the numbe of customers per order per day with multiple sizes in the order?

 

With the sample below, I would except the following:

Jan with 1 customer with multiple sizes in the order

Feb with 2 customers with multiple sizes in the order (Customer 222 is ignored because only 1 size in order)

 

I have tried COUNTROWS( Sales) and

 

COUNTROWS( DISTINCT( Sales[Size])) and

 

COUNTROWS (
  EXCEPT (
    VALUES ( Sales[Customer ID] ),
    SUMMARIZE (
      GENERATE (
      VALUES ( Sales[CustomerID] ),
      EXCEPT (
    VALUES ( Sales[Size] ),
    CALCULATETABLE ( VALUES ( Sales[Size] ) )
     )
    ),
  Sales[Customer ID]
  )
)
)

 

Any ideas?

 

DateCustomer IDOrder IDSize
1-Jan123ABC-10010
1-Jan123ABC-10012
3-Feb123ABC-11812
3-Feb123ABC-11814
7-Feb222ABC-22610
9-Feb125ABC-2348
10-Feb125ABC-23410
4 REPLIES 4
CNENFRNL
Community Champion
Community Champion

Screenshot 2021-06-22 120254.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Thanks, that worked as expected! What if I want to add another field to the table/measure? When I add a field after Customer ID the table goes blank? Same with [Size], could that be added to the table? It goes blank when I do.

 

# Multi Sizes =
VAR __grp =
ADDCOLUMNS (
SUMMARIZE ( ORDERS, ORDERS[Order ID], ORDERS[Customer ID], ORDERS[Type] ),
"@count", CALCULATE( DISTINCTCOUNT( ORDERS[Size] ) )
)
RETURN
COUNTROWS ( FILTER( __grp, [@count] > 1 ) )

 

I have a field called TYPE that I want to include. The result would be:

 

YYYYMMType# Multi Sizes
2021-01Dress1
2021-02Dress1
2021-02Top1

 

Data:

 

DateCustomer IDOrder IDSizeType
1-Jan123ABC-10010Dress
1-Jan123ABC-10012Dress
3-Feb123ABC-11812Dress
3-Feb123ABC-11814Dress
7-Feb222ABC-22610Pants
9-Feb125ABC-2348Top
10-Feb125ABC-23410Top
Jihwan_Kim
Super User
Super User

 

Picture1.png

 

Customers count multiple orders : =
IF (
ISFILTERED ( Dates[Month Name] ),
COUNTROWS (
SUMMARIZE (
FILTER (
ADDCOLUMNS (
SUMMARIZE ( Data, Dates[Month Name], Customers[Customer ID], Data[Order ID] ),
"@countorders", CALCULATE ( COUNTROWS ( VALUES ( Data[Size] ) ) )
),
[@countorders] > 1
),
Customers[Customer ID]
)
)
)
 
 
 

 

    Microsoft MVP




If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.





LinkedIn
Visit my LinkedIn page





Outlook Booking
Schedule a short Teams meeting to discuss your question.




Thanks, that worked as expected! I notice there is no total on this measure? Is there a way to add a total (3 in this case)?

 

What if I want to add another field to the table/measure? When I add a field after Customer ID the table goes blank? Same with [Size], could that be added to the table? It goes blank when I do.

 

Customers count multiple orders : =
IF (
ISFILTERED ( Dates[Month Name] ),
COUNTROWS (
SUMMARIZE (
FILTER (
ADDCOLUMNS (
SUMMARIZE ( Data, Dates[Month Name], Customers[Customer ID], Data[Order ID], Data[Type] ),
"@countorders", CALCULATE ( COUNTROWS ( VALUES ( Data[Size] ) ) )
),
[@countorders] > 1
),
Customers[Customer ID]
)
)
)

 

I have a field called TYPE that I want to include. The result would be:

 

YYYYMMType# Multi Sizes
2021-01Dress1
2021-02Dress1
2021-02Top1

 

Data:

 

DateCustomer IDOrder IDSizeType
1-Jan123ABC-10010Dress
1-Jan123ABC-10012Dress
3-Feb123ABC-11812Dress
3-Feb123ABC-11814Dress
7-Feb222ABC-22610Pants
9-Feb125ABC-2348Top
10-Feb125ABC-23410Top

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.