Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Need help to get DistinctCount of ColumnB (ServiceVisitYr) based on ColumnA (ServiceAddress)

Need help to get DistinctCount of ColumnB (ServiceVisitYr) based on ColumnA (ServiceAddress)

 

ServiceAddressServiceVisitYr
A12017
A12017
A12018
A12019
A12019
A22017
A22019
A32017
A32017
A32019
A42019
A42019
A52018

 

 

Expected Result

 

ServiceAddressServiceVisitYrDistinctYrs
A120173
A120173
A120183
A120193
A120193
A220172
A220192
A320172
A320172
A320192
A420191
A420191
A52018

1

 

 

Thanks for your help in advance.

2 REPLIES 2
Mariusz
Community Champion
Community Champion

HI @Anonymous 

 

You can create a measure like.

Measure = CALCULATE(
    DISTINCTCOUNT( 'Table'[ServiceVisitYr] ),
    ALL( 'Table'[ServiceVisitYr] )
)

or column like this.

Column = 
CALCULATE(
    DISTINCTCOUNT( 'Table'[ServiceVisitYr] ),
    ALL( 'Table'[ServiceVisitYr] )
)
Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

Anonymous
Not applicable

Thanks for your answer.

 

Your solution works in the data set presented above.

 

but, I have other columns in my table and to make it work I used

 

CALCULATE(DISTINCTCOUNT('Table'[ServiceVisitYr]), ALLEXCEPT('Table','Table'[ServiceAddress]))
 

The other problem is I'm using slicer on 

ServiceVisitYr
and when I filter data I do not get correct count

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors