This is best Fabric, Power BI, SQL and AI community event. How do we know? The last event sold out! Save €200 with code FABCMTY200.
Register nowA new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.
I need to calculate distinct count of each product (P1,P2,P3) which has sales grater than 0 and then sum and give me total Product count in a card visual. I have written a below DAX to get the count , but it is not giving me correct result.
TotalProductCount:=
SUMX (
VALUES ( Product[Location] ),
CALCULATE (
DISTINCTCOUNT( Product[ProductCode] ),
Product[SalesAmount] > 0))
expected output we need as 24
Sales=SUM(SalesAmount)
Also, P1,P2,P3 are the Measures
P1:= CALCULATE ([Sales], KEEPFILTERS(Product[ProductCode] = "P1"))
P2:= CALCULATE ([Sales], KEEPFILTERS(Product[ProductCode] = "P2"))
P3:= CALCULATE ([Sales], KEEPFILTERS(Product[ProductCode] = "P3"))
Solved! Go to Solution.
hello @amikm
Your dataset has no 0 values and null values does is not same as a 0.
so in my dataset i did not calculate values >0, but if in your dataset you expect to see 0, you can place that filter.
The best way to handle this is to transform the table like this :
once this is done, rest ofthe calculations are simeple.
Check out this pbix amikm_ jpssSol.pbix
if you find this helpful, consider marking this as a solution
hello @amikm
Your dataset has no 0 values and null values does is not same as a 0.
so in my dataset i did not calculate values >0, but if in your dataset you expect to see 0, you can place that filter.
The best way to handle this is to transform the table like this :
once this is done, rest ofthe calculations are simeple.
Check out this pbix amikm_ jpssSol.pbix
if you find this helpful, consider marking this as a solution
Check out the May 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 26 | |
| 24 | |
| 22 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 42 | |
| 42 | |
| 41 | |
| 21 | |
| 20 |