Forum Discussion
How to create a filter with count
- 4 years ago
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/
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/
Excellent! Very smart this double SUMMARIZE!
Thanks Tom