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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
kzielinska
Helper I
Helper I

Count of distinct values for each combination of two columns

Hi,

 

I have two tables.

For each unique combination of Employee and Location I want to count number of existing documents and create a new column in second table with the count only.

Screenshot (305).pngScreenshot (307).png

 

The result should be following:

Screenshot (306).png

 

In the report view, when I have a table with the final table, I also want to be able to filter out the dates based on the first table. So for example If I filter year 2000, for Jan & Poland I want to see Count of Documents = 1.

 

Can anyone help me with this?

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

If you want it to react to slicers and filters then you need to do it as a measure not as a calculated column.

First create a couple of dimension tables which you can link to your documents table and then create a measure

// New Table
Employee = DISTINCT('Documents'[Employee])

// New Table
Location = DISTINCT('Documents'[Location])

// Measure
Num documents = COUNTROWS('Documents')

 Put the columns from your new tables into a visual with the measure.

View solution in original post

4 REPLIES 4
johnt75
Super User
Super User

If you want it to react to slicers and filters then you need to do it as a measure not as a calculated column.

First create a couple of dimension tables which you can link to your documents table and then create a measure

// New Table
Employee = DISTINCT('Documents'[Employee])

// New Table
Location = DISTINCT('Documents'[Location])

// Measure
Num documents = COUNTROWS('Documents')

 Put the columns from your new tables into a visual with the measure.

Thank you! It works properly, but in some cases there are no documents for an employee, who is present only in the second table, and I also want to display this on my visual. What should I do in order to be able to see this information?

You could change the measure to be

Num documents = COALESCE( COUNTROWS('Documents'), 0)

Thank you a lot! It works perfectly

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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