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
fiorela
Helper I
Helper I

distinct count and group by

Hi there !

 

i would like your help on this. I dont know how to search and how to make the following calculation.

 

I have the following columns:

User   Session  Category

Juan    A                 Z
Maria  B                  Y 

Juan    C                 X

Juan    C                 X

Juan    A                 Y

Maria  C                  X 
Maria  B                  X 

so i would like to count by user, how many DISTINCT CATEGORY they have. For that i've created an unique user column, usar + session:

uniqueuser   countDISTINCTCategory

JuanA                 2

JuanC                  1

MariaB                 2

MariaC                 1

 

i think that i have to use group by, or something like that (DAX function). Any suggestions?

 

Thanks

1 ACCEPTED SOLUTION
az38
Community Champion
Community Champion

Hi @fiorela 

you dont need any additional columns, just try a measure

countDISTINCTCategory = calculate(DISTINCTCOUNT('Table'[Category]), ALLEXCEPT('Table', 'Table'[User]))

 

do not hesitate to give a kudo to useful posts and mark solutions as solution

 


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

View solution in original post

6 REPLIES 6
divsforeal
Frequent Visitor

hey

 

How to get this in power Query.

 

Thanks

PaulDBrown
Community Champion
Community Champion

@fiorela 

 

All you need is this measure;

Number of categories = DISTINCTCOUNT('DataTable CatUser'[Category])

 

And you can then create a table or matrix to display the breakdown by User or by User/Session:

Categories by User.JPG

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






thank you so much !!! works too

az38
Community Champion
Community Champion

Hi @fiorela 

you dont need any additional columns, just try a measure

countDISTINCTCategory = calculate(DISTINCTCOUNT('Table'[Category]), ALLEXCEPT('Table', 'Table'[User]))

 

do not hesitate to give a kudo to useful posts and mark solutions as solution

 


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

This measure works to me.

 

Thanks

let me try this, and i will let you know if that works. Thanks in advance

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.