Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredJoin us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.
I would like to create a short table showing how much customers have bought how much product,s and I'm struggling getting the COUNT or COUNTROWS working as an expression within CALCULATE/CALCULATETABLE.
Here my table :
And would like to get:
Nbr of Products Nbr of Customers
1 3
2 2
How do I do that with DAX?
Thanks
Solved! Go to Solution.
Hi @clo_64,
I think I got to a solution:
Here the DAX:
New Table =
VAR _helpTable =
SUMMARIZE (
TableCustomerProduct,
TableCustomerProduct[Customer],
"Nbr of Products", DISTINCTCOUNT ( TableCustomerProduct[Product] )
)
RETURN
SUMMARIZE (
_helpTable,
[Nbr of Products],
"Nbr of Customers",
CALCULATE (
DISTINCTCOUNT ( 'TableCustomerProduct'[Customer] ),
FILTER (
VALUES ( 'TableCustomerProduct'[Customer] ),
CALCULATE ( DISTINCTCOUNT ( TableCustomerProduct[Product] ) ) = [Nbr of Products]
)
)
)
The _helpTable does a grouping on customer with a distinct count on product. The return statement uses the Number of Products from the _helptable combined with a "having clause" in order to retrieve the number of customers per number of products
Let me know if this helps 🙂
/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/
| Did I answer your question❓➡️ Please, mark my post as a solution ✔️ |
| Also happily accepting Kudos 🙂 |
| Feel free to connect with me on LinkedIn! | |
| #proudtobeasuperuser | |
Hi @clo_64,
I think I got to a solution:
Here the DAX:
New Table =
VAR _helpTable =
SUMMARIZE (
TableCustomerProduct,
TableCustomerProduct[Customer],
"Nbr of Products", DISTINCTCOUNT ( TableCustomerProduct[Product] )
)
RETURN
SUMMARIZE (
_helpTable,
[Nbr of Products],
"Nbr of Customers",
CALCULATE (
DISTINCTCOUNT ( 'TableCustomerProduct'[Customer] ),
FILTER (
VALUES ( 'TableCustomerProduct'[Customer] ),
CALCULATE ( DISTINCTCOUNT ( TableCustomerProduct[Product] ) ) = [Nbr of Products]
)
)
)
The _helpTable does a grouping on customer with a distinct count on product. The return statement uses the Number of Products from the _helptable combined with a "having clause" in order to retrieve the number of customers per number of products
Let me know if this helps 🙂
/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/
| Did I answer your question❓➡️ Please, mark my post as a solution ✔️ |
| Also happily accepting Kudos 🙂 |
| Feel free to connect with me on LinkedIn! | |
| #proudtobeasuperuser | |
Excellent! Very smart this double SUMMARIZE!
Thanks Tom
Hi,
Coulld you explain why you have 2 2 on the second line of your output? Shouldn't it be 2 1, as only the customer Gamma has bought 2 products?
Best regards.
Because Ypsilon has also bought 2 distint products.
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 11 | |
| 9 | |
| 8 | |
| 6 | |
| 6 |