Forum Discussion
Anonymous
6 years agoNot applicable
Get DistinctCount of ColumnB based on ColumnA
Need help to get DistinctCount of ColumnB (ServiceVisitYr) based on ColumnA (ServiceAddress)
| ServiceAddress | ServiceVisitYr |
| A1 | 2017 |
| A1 | 2017 |
| A1 | 2018 |
| A1 | 2019 |
| A1 | 2019 |
| A2 | 2017 |
| A2 | 2019 |
| A3 | 2017 |
| A3 | 2017 |
| A3 | 2019 |
| A4 | 2019 |
| A4 | 2019 |
| A5 | 2018 |
Expected Result
| ServiceAddress | ServiceVisitYr | DistinctYrs |
| A1 | 2017 | 3 |
| A1 | 2017 | 3 |
| A1 | 2018 | 3 |
| A1 | 2019 | 3 |
| A1 | 2019 | 3 |
| A2 | 2017 | 2 |
| A2 | 2019 | 2 |
| A3 | 2017 | 2 |
| A3 | 2017 | 2 |
| A3 | 2019 | 2 |
| A4 | 2019 | 1 |
| A4 | 2019 | 1 |
| A5 | 2018 | 1 |
Thanks for your help in advance.
- Anonymous6 years agoMeasure = CALCULATE(DISTINCTCOUNT('Table'[ServiceVisitYr]),ALLSELECTED('Table'[ServiceVisitYr]))
3 Replies
- AnonymousNot applicableCALCULATE(DISTINCTCOUNT(Test[ServiceVisitYr]),ALLEXCEPT(Test,Test[ServiceAddress]))
- AnonymousNot applicable
Thanks for your answer.
Your solution works in the data set presented above.
The other problem is I'm using slicer on
ServiceVisitYr
and when I filter data I do not get correct count- AnonymousNot applicableMeasure = CALCULATE(DISTINCTCOUNT('Table'[ServiceVisitYr]),ALLSELECTED('Table'[ServiceVisitYr]))