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

DistinctCount grouping by

Hi, I've never understood how to do a distinct count with a group by on a visual that has many fields included the one I want to distinct count. I explain my problem with an example:

I have this visual

1 | 2 | 3 | 4 

----------------

A | W | G | K

A | S | G | J

A | C | N | J

B | V | N | K

B | Q | N | J

B | L | I | K

B | D | O | K

 

I want to do a distinct count of 1 grouping by 3 on column 5 to have this result:

1 | 2 | 3 | 4 | 5

----------------

A | W | G | K | 2

A | S | G | J | 2

A | C | N | J | 1

B | V | N | K | 2

B | Q | N | J | 2

B | L | I | K | 1

B | D | O | K | 1

 

I tried a formula like this: 

result = CALCULATE(DISTINCTCOUNT('Table1'[1]), GROUPBY('Table2','Table2'[3]))
but the result I obtain is this:

1 | 2 | 3 | 4 | 5

----------------

A | W | G | K | 1

A | S | G | J | 1

A | C | N | J | 1

B | V | N | K | 1

B | Q | N | J | 1

B | L | I | K | 1

B | D | O | K | 1

 

What formula can I use with DISTINCTCOUNT? Thanks

1 REPLY 1
Jihwan_Kim
Super User
Super User

Picture1.png

 

5 CC =
VAR currentthree = 'Table'[3]
VAR currentone = 'Table'[1]
VAR groupbythree =
FILTER ( 'Table', 'Table'[3] = currentthree && 'Table'[1] = currentone )
RETURN
COUNTROWS ( groupbythree )
 
 
 
 

 

    Microsoft MVP




If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.





LinkedIn
Visit my LinkedIn page





Outlook Booking
Schedule a short Teams meeting to discuss your question.




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.