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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Distinct Count Based on Multiple Dynamic Column Filters

I want to create a measure that counts distinct visit days (metric date) per customer that changes based on brand, channel and date filters. This is an example of the table that I have:

 

bi_baller_0-1597653600759.png

With the above in mind, if Brand ID = 2 is filtered on report, it should show 2 distinct visit days. 

If Brand = 2 and Channel = 3, it should show 1.

If Customer ID = 1 & 2, it should show 2 visit days. 

 

A distinctcount will obviously exclude the same visit day across customers. I don't know how to amend this to get a count of unique metric dates per customer that then also changes depending on brand and channel filters.

 

If anyone can help that would be greatly appreciated.

1 ACCEPTED SOLUTION
Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

Try this Measure.

Measure = 
COUNTROWS(
    SUMMARIZE( 'Table', 'Table'[Customer ID], 'Table'[metric date] )
)

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn


 

View solution in original post

5 REPLIES 5
Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

Try this Measure.

Measure = 
COUNTROWS(
    SUMMARIZE( 'Table', 'Table'[Customer ID], 'Table'[metric date] )
)

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn


 

Anonymous
Not applicable

Here is an example of some of the data from one customer:

 

bi_baller_1-1597682775796.png

 

Using COUNTROWS(SUMMARIZE('Table', customer_id, metric_date)) works when filtering by brand or channel, however, unfiltered this shows the number of visit days as 5. However, this should show as 4 since there are only 4 unique metric dates.

 

Calling @Anonymous for a solution on this one (if that's acceptable). Please help

Anonymous
Not applicable

Hi there.

The formula COUNTROWS(SUMMARIZE('Table', customer_id, metric_date)) is correct and should show 4 for an unfiltered table. If you get 5, please create a calculated table with the formula SUMMARIZE('Table', customer_id, metric_date) and see what it returns. It should return 4 rows. If it returns 5, as you claim, something's wrong with your data types.
Anonymous
Not applicable

@Mariuszthis works when filtering on brand and channel but across the entire table, unfiltered, I get too many records. It looks like some dates are being double counted.

 

Any thoughts?

amitchandak
Super User
Super User

@Anonymous , Try like can help

sumx(summarize(Table,Table[Customer ID],Table[Channel],"_1",distinctcount(Table[Date])),[_1])

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.