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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. 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]
)
)
)
 
 
 

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.


Click here to visit my LinkedIn page

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
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.