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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
raj-ascendum
New Member

Using ALL()

Hi,
I am trying to get a table variable with all filters removed from 'Table 1' and data within a user selected 'Start' & 'End' date from a 'Date' table 

 (a)-      Using All( ) returns the whole 'Table 1', ignoring even the filter applied by the 'DATESBETWEEN' 
                    CALCULATETABLE ( All( 'Table 1')
                                                   ,DATESBETWEEN('Table 1'[Reporting Date], start_date, end_date)
                                                    )
 (b)-     Using : without All( ) works as desired by the 'DATESBETWEEN'
                            CALCULATETABLE ( 'Table 1'
                                                            ,DATESBETWEEN('Table 1'[Reporting Date], start_date, end_date)
                                                          )

Not using ALL() applies the filter applied by the 'DATESBETWE
EN', whereas ALL() removes the filter of 'DATESBETWEEN'.

Please help.
1 ACCEPTED SOLUTION

CALCULATETABLE() invokes context transition, and as I said, DATESBETWEEN() is meant to work only on date tables which have a hidden ALL() filter on them. Your data table is not a date table, so using DATESBETWEEN() on it will cause problems. DATESBETWEEN() returns a table, whereas the filter critera I set up will filter the records that the FILTER() function iterates on. In other words, it looks at every record and evaluates what does and doesn't fall in between the dates. It keeps those that do. DATESBETWEEN() returns a table with all dates from a valid date table between the start/end date, it does not filter data in normal date columns.

 

It goes beyond the scope of this forum to really dig into context transition and Time Intelligence functions. THere are some really good chapters on this in the Definitive Guide to DAX Second Edition book. But the short answer is, unless you are using a time intelligence function, do not use any Time Intellgence functions like DATESBETWEEN or LASTDATE. They will not work properly or efficiently if used as normal functions.

 

If my answer helped, please mark it as a solution so this thread can be known to be solved. Thanks!



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

4 REPLIES 4
raj-ascendum
New Member

Thanks for guiding.
I will dig deeper in the book.

raj-ascendum
New Member

Thanks a lot Edhans,
I modified the DATESBETWEEN  to  <  & > and used FILTER. It works as desired.
I am trying to get a deeper understanding of Why Calculatetable with ALL() returns all the records ignoring the Dates ( <= & >= ) filter, whereas Filter() with ALL() returns records after applying the dates filter.

I am asking this because I have a number of measures desinged that way with 'CALCULATETABLE', I will have to update all of them.

 


 

CALCULATETABLE() invokes context transition, and as I said, DATESBETWEEN() is meant to work only on date tables which have a hidden ALL() filter on them. Your data table is not a date table, so using DATESBETWEEN() on it will cause problems. DATESBETWEEN() returns a table, whereas the filter critera I set up will filter the records that the FILTER() function iterates on. In other words, it looks at every record and evaluates what does and doesn't fall in between the dates. It keeps those that do. DATESBETWEEN() returns a table with all dates from a valid date table between the start/end date, it does not filter data in normal date columns.

 

It goes beyond the scope of this forum to really dig into context transition and Time Intelligence functions. THere are some really good chapters on this in the Definitive Guide to DAX Second Edition book. But the short answer is, unless you are using a time intelligence function, do not use any Time Intellgence functions like DATESBETWEEN or LASTDATE. They will not work properly or efficiently if used as normal functions.

 

If my answer helped, please mark it as a solution so this thread can be known to be solved. Thanks!



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
edhans
Community Champion
Community Champion

DATESBETWEEN() is a time intelligence function and should only be used on a date table. Try this:

 

Test Measure =
    FILTER(
        ALL('Table 1'),
        'Table 1'[Reporting Date] >= start_date
            && 'Table 1'[Reporting Date] <= end_date
    )

I'm not sure why you need CALCULATETABLE here, but you can wrap the above in that if you are needing some particular context transition. FILTER() returns a table.

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.