March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
OK, pretty simple question, I think. I have customers. They have invoices. Using Slicers, I can choose a customer, and show many invoices they have, or build a matrix to show each customer and how many thay have each.
I can choose a date range, and show how many total invoices were shipped within that range, with a matrix by customer.
What I want to show, however is how many customers ordered exactly 5 times, how many ordered exactly 4 times, how many ordered exactly three times, etc. within that date range.
I am not sure quite how to go about this in DAX. I can get specific if I need to, but I think just the general concept would be enough to get me where I need to be.
Thank for any assistance.
Phil
Solved! Go to Solution.
Try this Calculated Table
from the Modelling tab >>New Table
Table = SUMMARIZE ( SUMMARIZE ( CustomerTable, CustomerTable[Customer Name], "Order_Count", COUNTROWS ( InvoiceTable ) ), [Order_Count], "Count of Customers with", COUNT ( CustomerTable[Customer Name] ) )
Hi,
Share some data and show the expected result.
InvoiceTable | ||
Invoice# | Customer# | Invoice Amount |
1001 | 4 | $ 637.97 |
1002 | 3 | $ 456.71 |
1003 | 1 | $ 619.04 |
1004 | 1 | $ 992.96 |
1005 | 3 | $ 987.20 |
1006 | 4 | $ 194.08 |
1007 | 4 | $ 35.97 |
1008 | 1 | $ 479.84 |
1009 | 1 | $ 929.18 |
1010 | 2 | $ 271.85 |
1011 | 3 | $ 288.53 |
1012 | 1 | $ 219.49 |
CustomerTable | |
Customer # | Customer Name |
1 | Joe |
2 | Fred |
3 | Mark |
4 | Nathan |
With this DAX: Orders_Count = Calculate(DISTINCTCOUNT(InvoiceTable[invoice#]))
I can get this result:
Customer Name | Order_Count |
Joe | 5 |
Fred | 1 |
Mark | 3 |
Joe | 3 |
Now I want the Next Level:
Count_Of_Customers_With | Order_Count |
1 | 1 |
2 | 3 |
1 | 5 |
If I know how to count the count, I should be able to figure out how to Slice and sort by count. For instance, Customer with most orders on top. Customers with 100 orders.
I am trying to wrap my head around the suggestion offered in the previous post. It is not quite gelling for me.
Thanx for any help.
Try this Calculated Table
from the Modelling tab >>New Table
Table = SUMMARIZE ( SUMMARIZE ( CustomerTable, CustomerTable[Customer Name], "Order_Count", COUNTROWS ( InvoiceTable ) ), [Order_Count], "Count of Customers with", COUNT ( CustomerTable[Customer Name] ) )
Thank you. I was able to adapt that to my PBIX, and now I understand how Summarize works. Previous explanations were a little too generic to wrap my head around.
Thank You.
It works with the sample data
This looks like a measure aggregation problem. See my blog article about that here: https://community.powerbi.com/t5/Community-Blog/Design-Pattern-Groups-and-Super-Groups/ba-p/138149
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
134 | |
91 | |
89 | |
64 | |
58 |
User | Count |
---|---|
201 | |
137 | |
107 | |
72 | |
68 |