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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

All/Removefilters not working with dates

Hello, I'm trying to count the number of distinct dates. The result should be 9 (see table below).

 

guillaume_boism_0-1636735806520.png

 

1) I tried the measure below, but the result is only the distinct count for each month, which is not right. I used the datefield in the matrix and the formula.

Mesure 2 = calculate(DISTINCTCOUNT(Table1[Date]),REMOVEFILTERS(Table1[Date]))

guillaume_boism_2-1636736034155.png

 

2) I created a month field in my table (see at the top), and used it in the formula and the matrix and it worked.

Mesure 2 = calculate(DISTINCTCOUNT(Table1[Date]),REMOVEFILTERS(Table1[Month]))

 

guillaume_boism_3-1636736190562.png

I don't understand why my first measure is not working. I don't want to use a month field because it is not sorting properly in the matrix (sorts alphabetically). I tried with ALL and the result was the same. What do I need to do to make it work with date field?

 

Thank you

 

1 ACCEPTED SOLUTION

There are a variety of ways to deal with this.

 

One option would be something like this:

Mesure2 =
IF (
    ISEMPTY ( Table1 ),
    BLANK (),
    CALCULATE ( DISTINCTCOUNT ( Table1[Date] ), REMOVEFILTERS ( 'Date' ) )
)

View solution in original post

12 REPLIES 12
PaulDBrown
Community Champion
Community Champion

To sort the month chronologically you need to add a column in the table with the month number using

Month Number = MONTH (Table[Date])

you then select the month name column in the table, select the option "Sort column by" in the ribbon and choose the month number column. Now the month name field will be ordered chronologically in the visuals.





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.






Anonymous
Not applicable

Hello, yes I already tried that and it gives the wrong result as well. Thank you

Ashish_Mathur
Super User
Super User

Hi,

Why can we not use this simple measure

Measure1 = distinctcount(Table1[Date])

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Hello, because it will give the same result as my measure in Example 1. Thank you

Share the link from where i can download your PBI file and show the expected problem very clearly.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Hello, the solution is now in the post. Thank you

AlexisOlson
Super User
Super User

In the first example, you aren't really using Date on the matrix rows but rather the month within the Date hierarchy, so clearing the filters on Date doesn't automatically remove the filters on the month part.

 

The best solution to this sort of problem is to use a proper date dimension table. Check out this article for more about why this is important and how to do it:
https://radacad.com/do-you-need-a-date-dimension

 

Anonymous
Not applicable

Hello @AlexisOlson , I already knew about date tables and I read your link to make sure I understood everything. I created a date table but the results are the same. Date is a hierarchy and monthname can't be sorted. Can you please elaborate on how to set-it up to make my measure work. Thank you

If you have a date table, then you can use REMOVEFILTERS ( DateTable ) instead of REMOVEFILTERS ( DateTable[Date] ) and it should clear all of the date filter context.

Anonymous
Not applicable

Hello @AlexisOlson , it does indeed but it creates another problem. It now populate months where I don't have any data. Thank you

 

Mesure 2 = calculate(DISTINCTCOUNT(Table1[Date]),REMOVEFILTERS('Date'))

 

guillaume_boism_0-1636821114132.png

 

There are a variety of ways to deal with this.

 

One option would be something like this:

Mesure2 =
IF (
    ISEMPTY ( Table1 ),
    BLANK (),
    CALCULATE ( DISTINCTCOUNT ( Table1[Date] ), REMOVEFILTERS ( 'Date' ) )
)
Anonymous
Not applicable

Thank you!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors