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! Request now

Reply
Anonymous
Not applicable

the difference between filter() and datesbetween()

Hi, 

 

I'm trying to understand the difference between the two measures below. I thought they will generate the same results, except option1 filters calendar[Date] through filter() function while option 2 filter calendar[Date]  via datesbetween(). 

 

However, these two measures generate different results. It looks filter() always take current filter context (year-month) as a default context and apply conditions on top of it. Datesbetween () take the whole calendar[Date] as the starting point, ignoring date context in the matrix table context. 

 

Is that normal that datesbetween behaves this way? I have never heard of a function (except "all()", "allexcept()") that would ignore current filtering context automatically. 

 

 

option1

Rolling 12 Months #Exits =
VAR Maxdate =
MAX ( 'Calendar'[Date] )
VAR Mindate = Maxdate -364
RETURN
CALCULATE (
COUNTROWS ( Headcount ),
USERELATIONSHIP ( 'Calendar'[Date], Headcount[Exit Date] ),
NOT ISBLANK ( Headcount[Exit Date] ),
FILTER (
'Calendar',
AND (
'Calendar'[Date] <= Maxdate,
Calendar[Date] > Mindate
)
)
)
 opt 2
#leavers 2 =
VAR maxdate = MAX ( 'Calendar'[Date] )
VAR mindate = maxdate - 364
VAR rolling_12_month_leavers =
CALCULATE (
COUNTROWS ( Headcount ),
NOT ISBLANK ( Headcount[Exit Date] ),
USERELATIONSHIP ( 'Calendar'[Date], Headcount[Exit Date] ),
DATESBETWEEN (
'Calendar'[Date],
mindate,
maxdate
)
)
RETURN
rolling_12_month_leavers
two types of filter.PNG
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , time intelligence function is used outside filter function has a different impact than the one you have used in filter

refer if this can help

http://dataap.org/blog/2019/04/22/difference-between-calculate-with-and-without-filter-expression/

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

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@Anonymous , time intelligence function is used outside filter function has a different impact than the one you have used in filter

refer if this can help

http://dataap.org/blog/2019/04/22/difference-between-calculate-with-and-without-filter-expression/

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

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