Forum Discussion
Summing with distinct values
how can i get a sum of all values of three columns (minor, major, critical) but only distinct values based on the ID column. My data has repeating rows and I can't remove because I'm using other fields value. (ex. since ID 14 is repeating, we would only count that once)
| ID | Minor Total | Major Total | Critical Total |
| 12 | 2 | 1 | 0 |
| 10 | 0 | 2 | 1 |
| 11 | 1 | 11 | 0 |
| 13 | 3 | 3 | 3 |
| 14 | 4 | 0 | 1 |
| 14 | 4 | 0 | 1 |
| 15 | 5 | 0 | 0 |
| 14 | 4 | 0 | 1 |
| 14 | 4 | 0 | 1 |
jcastr02 , Create measure like this for all three columns
sumx(summarize(Table,Table[ID], Table[Minor Total]),[Minor Total])
sumx(summarize(Table,Table[ID], Table[Major Total]),[Major Total])
sumx(summarize(Table,Table[ID], Table[Critical Total]),[Critical Total])
3 Replies
- amitchandak
Super User
jcastr02 , Create measure like this for all three columns
sumx(summarize(Table,Table[ID], Table[Minor Total]),[Minor Total])
sumx(summarize(Table,Table[ID], Table[Major Total]),[Major Total])
sumx(summarize(Table,Table[ID], Table[Critical Total]),[Critical Total])
- mhossain
Solution Sage
In adition to amitchandak 's dax, you can also try below measure:
DistinctCount based on 3 cols =CALCULATE(DISTINCTCOUNT('Table'[ID]) , 'Table'[Minor Total]>0)+CALCULATE(DISTINCTCOUNT('Table'[ID]) , 'Table'[Major Total]>0)+CALCULATE(DISTINCTCOUNT('Table'[ID]) , 'Table'[Critical Total]>0) - v-jingzhang
Community Support
Try Amit's codes and add up all of them into a measure like below, this should work.
Measure = sumx(summarize('Table','Table'[ID], 'Table'[Minor Total]),[Minor Total]) + sumx(summarize('Table','Table'[ID], 'Table'[Major Total]),[Major Total]) + sumx(summarize('Table','Table'[ID], 'Table'[Critical Total]),[Critical Total])You can also try this measure:
Measure 2 = SUMX(SUMMARIZE('Table','Table'[ID],'Table'[Minor Total],'Table'[Major Total],'Table'[Critical Total]),'Table'[Minor Total]+'Table'[Major Total]+'Table'[Critical Total])Regards,
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.