Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi guys,
I'm now building a DAX that will show us the total count of customer by the number of purchased product with total sales is large than 0 in the matrix table when we filter year & month as my below picture.-
I have tried all the dax on google but can't find the good solution so I hope you can help me. Here is the link of my files. Thank you in advance!
Solved! Go to Solution.
@blader1989
Assuming your sales measure name is [SalesAmount]
DistinctCountOfCustomers =
Var __productCount = MAX(Query1[NoOfProducts])
Var __Customers = ADDCOLUMNS(Filter(VALUES(raw[Customer Code]), [SalesAmount] >0 ), "ProductCount", CALCULATE( COUNTROWS(VALUES(raw[Product Name]))))
var Result = FILTER(__Customers, [ProductCount] = __productCount)
RETURN COUNTROWS(Result)
If the post helps please give a thumbs up
If it solves your issue, please accept it as the solution to help the other members find it more quickly.
Tharun
@blader1989
I think there are many ways to achieve this result, one approach that I could suggest is:
create a list of numbers from 1 to n (distinct count of products) and created a measure to find number of customers:
DistinctCountOfCustomers =
Var __productCount = MAX(Query1[NoOfProducts])
Var __Customers = ADDCOLUMNS(VALUES(raw[Customer Code]), "ProductCount", CALCULATE( COUNTROWS(VALUES(raw[Product Name]))))
var Result = FILTER(__Customers, [ProductCount] = __productCount)
RETURN COUNTROWS(Result)
If you want you can filter out customers whose total sale value is less than zero.
I am attaching the file here:
If the post helps please give a thumbs up
If it solves your issue, please accept it as the solution to help the other members find it more quickly.
Tharun
Hi @tharunkumarRTK , thank you for your solution. It's look promising so how can I add the condition that the total sales is large than 0 in your formula? In my power BI file, I already have the totalsales DAX.
@blader1989
Assuming your sales measure name is [SalesAmount]
DistinctCountOfCustomers =
Var __productCount = MAX(Query1[NoOfProducts])
Var __Customers = ADDCOLUMNS(Filter(VALUES(raw[Customer Code]), [SalesAmount] >0 ), "ProductCount", CALCULATE( COUNTROWS(VALUES(raw[Product Name]))))
var Result = FILTER(__Customers, [ProductCount] = __productCount)
RETURN COUNTROWS(Result)
If the post helps please give a thumbs up
If it solves your issue, please accept it as the solution to help the other members find it more quickly.
Tharun
Hi @tharunkumarRTK , thank you so much. I have added your approach and it's look very good now we are facing new challegening and I hope you can help us that when we click the number of SKUs purchase group on the matrix table, it will only show us which product and customer code in the 2 tables below?
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
107 | |
88 | |
76 | |
67 |
User | Count |
---|---|
126 | |
111 | |
100 | |
83 | |
71 |