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
merinadica
Frequent Visitor

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 @merinadica 

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 @merinadica 

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

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 @merinadica 

You would just change it to:

Users = DISTINCTCOUNT( mockup[User] )

 

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
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.