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
Sabri-All
Regular Visitor

User filter doesn't apply on distinctcount

Hello, 

 

I have two tables

  • Orders (column: ID, accountId, date, type)
  • Accounts (column: accountId, Name)

The purpose is to get for every account the number of unique order types. For example, if an account have 5 orders (2 of type A, 1 of type B and one of type C), I should get 3 as number. For that I used this measure:

CALCULATE(DISTINCTCOUNT(Orders[Type]).
 
It works fine, but when I add a visual filter on date, and I try to change the dates of orders, I don't get the correct values. Exemple:
  • AccountX | 01/01/2019 | Type A
  • AccountX | 01/01/2020 | Type B
  • AccountX | 01/01/2021 | Type A
Without filter, value is 2. If I filter on 2021, I get also 2. I think it checks if the account has an order in 2021 and if so it shows the value that is already calculated. 
 
How can I manage to make it calculte after the users does the visual filters?
 
Thank you in advance.
1 ACCEPTED SOLUTION
v-robertq-msft
Community Support
Community Support

Hi, 

According to your description, I can roughly understand your requirement, I also created some sample data and I can successfully get the correct count value using the DAX formula:

Count of unique order types =

CALCULATE(DISTINCTCOUNT(Orders[type]),ALLSELECTED(Orders))

Then I go to check the interaction type between the slicer and the visuals to make sure they are enabled:

vrobertqmsft_0-1643788616426.png

 

And I can get what you want, like this:

vrobertqmsft_1-1643788616428.png

vrobertqmsft_2-1643788616432.png

 

You can download my test pbix file below

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-robertq-msft
Community Support
Community Support

Hi, 

According to your description, I can roughly understand your requirement, I also created some sample data and I can successfully get the correct count value using the DAX formula:

Count of unique order types =

CALCULATE(DISTINCTCOUNT(Orders[type]),ALLSELECTED(Orders))

Then I go to check the interaction type between the slicer and the visuals to make sure they are enabled:

vrobertqmsft_0-1643788616426.png

 

And I can get what you want, like this:

vrobertqmsft_1-1643788616428.png

vrobertqmsft_2-1643788616432.png

 

You can download my test pbix file below

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Sabri-All , Accounts is joined with the order and Account filter order table?

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

There is a relation on accountid 1:N. 

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.