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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Distinct count over 3 columns

Hi,
I'm trying to add a new calculated column for the count of customer accounts per user (Name) in my data set.
How do I do this?
I only need the count for specific years. Like in the example table below, Kalvin would show 2 in the new column for 2020 and 1 for 2021.

NameAcc noYear
Josh1Dec23
Kalvin20Dec20
Basey3Dec21
Kalvin20Dec20
Kalvin20Dec21
2 ACCEPTED SOLUTIONS
TomMartens
Super User
Super User

Hey @Anonymous ,

 

You can use DAX statement to create a calculated column:

Column = 
var currentName = 'Table'[Name]
var currentYear = 'Table'[Year]
return
COUNTROWS(
    FILTER(
        'Table'
        , 'Table'[Name] = currentName && 'Table'[Year] = currentYear
    )
)

The table will look like this (do not wonder about the year column, this happened by pasting your data into a table):

TomMartens_0-1711607155990.png

Hopefully, this provides what you are looking for.

 

Regards,

Tom

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

Shreeram04
Resolver III
Resolver III

Hi @TomMartens 

 

Please find the below measure and screenshot for your reference.

Customer Count =
CALCULATE(
    COUNTROWS('AA'),
    ALLEXCEPT('AA', 'AA'[Name], 'AA'[Year])
)


Shreeram04_0-1711607554232.png

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

Thanks,

Hari R

 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

@TomMartens  @Shreeram04  thank you both

Shreeram04
Resolver III
Resolver III

Hi @TomMartens 

 

Please find the below measure and screenshot for your reference.

Customer Count =
CALCULATE(
    COUNTROWS('AA'),
    ALLEXCEPT('AA', 'AA'[Name], 'AA'[Year])
)


Shreeram04_0-1711607554232.png

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

Thanks,

Hari R

 

TomMartens
Super User
Super User

Hey @Anonymous ,

 

You can use DAX statement to create a calculated column:

Column = 
var currentName = 'Table'[Name]
var currentYear = 'Table'[Year]
return
COUNTROWS(
    FILTER(
        'Table'
        , 'Table'[Name] = currentName && 'Table'[Year] = currentYear
    )
)

The table will look like this (do not wonder about the year column, this happened by pasting your data into a table):

TomMartens_0-1711607155990.png

Hopefully, this provides what you are looking for.

 

Regards,

Tom

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.