Forum Discussion
JM_nxgn
Helper I
7 years agoDAX DistinctCount with SUMX totals
Hi, I know there are quite a few of these posts but I feel my case is a bit different since it has quite a few moving parts. I've tried various things and I'm still struggling to find a solution, hop...
- 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.
JM_nxgn
Helper I
7 years agoThe 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-xicai
Community Support
7 years agoHi 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.