Forum Discussion
DAX DistinctCount with SUMX totals
- 7 years ago
Hi JM_nxgn ,
You can create measure like DAX below.
Sales = var d= CALCULATE(DISTINCTCOUNT(table[customer_id]), table[issold] = TRUE()) VAR _table = SUMMARIZE(table, table[Product_ID],"_Value", d) RETURN IF(HASONEVALUE(table[Product_ID]),d,SUMX(_table,[_Value]))
Best Regards,
Amy
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi JM_nxgn ,
For the sample data pasted what is the output you expect.
Also if you can load the data to Google or One Drive and share the link it will help find a solution.
Cheers
CheenuSing
The expected output would be what I have below. Unfortunately I can't provide the dataset as it contains sensitive information, I tried to recreate the situation as much as possible.
| Product_ID | Sales | |
| Prod - 1 | 1 | |
| Prod - 2 | 2 | |
| Prod - 3 | 1 | |
| Prod - 4 | 1 | |
| Prod - 5 | 1 | |
| Prod - 6 | 3 | |
| TOTAL | 9 |
- v-xicai7 years ago
Community Support
Hi JM_nxgn ,
You can create measure like DAX below.
Sales = var d= CALCULATE(DISTINCTCOUNT(table[customer_id]), table[issold] = TRUE()) VAR _table = SUMMARIZE(table, table[Product_ID],"_Value", d) RETURN IF(HASONEVALUE(table[Product_ID]),d,SUMX(_table,[_Value]))
Best Regards,
Amy
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- JM_nxgn7 years ago
Helper I
This worked for me thanks.