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

Dax: Distintcount values based on other row repetition

Hi,

I have the following table 

UserCountry
1Germany
2France
3Spain
4Germany
5Spain
6Germany
7Italy

I would like to count the distinct users that belong to countries where there are more users (so duplicated countries)

In this example, users from Germany and Spain.

I was able to count the repeated countries with something like this...

COUNTROWS(

          FILTER(

                    DISTINCT(country),CALCULATE(DISTINCTCOUNT(User)>1)))

...but I need to count the distinct users. I also thought of doing a summarize, but the table is too big and I'm worried about the performance with it.

Any help is more than welcome.

 

Thanks in advance!!

 

Javi

 

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, thanks to both of you for the support.

I think @amitchandak approach is the right one but I want the users instead of the countries and to Sum them instead of the Count because you are aggregating them in that summarize.

This is currently working.

SUMX( FILTER( SUMMARIZE( Location, Location[Country], "Users",DISTINCTCOUNT(Location[User]) ) ,[Users]>1 ) ,[Users])

 

Thanks a lot!!

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

@Anonymous  Hey Mate ,
You can use this function 
User = 

COUNTROWS(

          FILTER(

                    values(country),
                    CALCULATE(DISTINCTCOUNT(User)>=1)
                  )
                 )
or

COUNTROWS(

          FILTER(

                    values(country),
                    CALCULATE(DISTINCTCOUNT(User))
                  )
                 )


Thank you 

amitchandak
Super User
Super User

@Anonymous , try like

countx(filter(summarize(Table, Table[country], "_1",DISTINCTCOUNT(Table[User])),[_1]>1 ),[country])

Anonymous
Not applicable

Hi, thanks to both of you for the support.

I think @amitchandak approach is the right one but I want the users instead of the countries and to Sum them instead of the Count because you are aggregating them in that summarize.

This is currently working.

SUMX( FILTER( SUMMARIZE( Location, Location[Country], "Users",DISTINCTCOUNT(Location[User]) ) ,[Users]>1 ) ,[Users])

 

Thanks a lot!!

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.