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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

counting unique value based on multiple column values that changes with Filter

Hi All,

I am trying to change the value of a alculated coulmn based on filtere selection.

I have the following table with columns ( software, user, region ) and have created the total unique number of user that uses a software.

 

Capture.PNG

I have done it two seperate ways so far:

1) a calculated column :

column = CALCULATE(DISTINCTCOUNT(mockup[User]),ALLexcept(mockup,mockup[software]))

2) a calculated table :

Table =SUMMARIZE(mockup,mockup[software],"distinct users",CALCULATE(DISTINCTCOUNT(mockup[user]))) 

which works well:

Capture.PNG

but if I want to add a slicer based on region the values do not change. I would like to to see this when US is selected on the slicer:

Ansys        1               ------  (only user A)

Coreo        2              ------  (user A+D)

Microsoft  2               ------  (user A+D)

 

Can anyone help to fix this?

Thank you

 

2 ACCEPTED SOLUTIONS
jdbuchanan71
Super User
Super User

Hello @Anonymous 

It seems like just a simple measure would do what you want.

Users = DISTINCTCOUNT( software[User] )

It respects whatever filter flows into the measure (row, column, slicer, etc).

softwareusers.jpg

View solution in original post

I'm not sure what extra steps you're taking here. 

You literally create a new measure with this expression and put it into the table with the software

UserCount = DISTINCTCOUNT(mockup[user])

You don't even need to use a measure for something this simple.  You can drag User into the values, click the down arrow, and select Count(distinct).

 

Here's a .pbix with the data you gave and a table with 2 ways of counting users: https://drive.google.com/open?id=15Hxkc2p0D82A7S_t7MOjI2tOn40kGbgK

View solution in original post

6 REPLIES 6
jdbuchanan71
Super User
Super User

Hello @Anonymous 

It seems like just a simple measure would do what you want.

Users = DISTINCTCOUNT( software[User] )

It respects whatever filter flows into the measure (row, column, slicer, etc).

softwareusers.jpg

Anonymous
Not applicable

Hi @jdbuchanan71 

Thank you for taking your time to reply to my post. 

I was not able to replicate your formula can you explain more on how to apply it?

just to be more accurate, my table name is "mockup" with three columns with names "software","user" and "region" . in your formula I see that "user" is a column of table "software". could you please calify more ?

 

Thank you,

 

Hello @Anonymous 

You would just change it to:

Users = DISTINCTCOUNT( mockup[User] )

 

Anonymous
Not applicable

Hi @jdbuchanan71 

This is what I get when US is filtered:

Capture.PNG

and the table with no filter applied :

 

Capture.PNGI

I am not sure what I am missing here.

I'm not sure what extra steps you're taking here. 

You literally create a new measure with this expression and put it into the table with the software

UserCount = DISTINCTCOUNT(mockup[user])

You don't even need to use a measure for something this simple.  You can drag User into the values, click the down arrow, and select Count(distinct).

 

Here's a .pbix with the data you gave and a table with 2 ways of counting users: https://drive.google.com/open?id=15Hxkc2p0D82A7S_t7MOjI2tOn40kGbgK

Don't add my formula as a calculated column, add it as a measure.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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