Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

DAX ALL not working as expected using date

Hi,   I have a measure that aggregate sales for the last seven days, see below. I want this to ignore the date slicer. However that isn't happening. The value should be £220.77K for the last seven ...
  • johnt75's avatar
    4 years ago

    The ALL('Calendar'[Date]) is not being applied to the DATESBETWEEN function, it is only being applied to the [Sum_gross_sales] measure, so when you call MAX('Calendar'[Date]) the slicer is still in effect. 

    If your Calendar table is marked as a date table then you don't need to remove filters from the 'Calendar'[Date] column if you apply another filter to that column, DAX takes care of that automatically. Try using

    Last 7 days = CALCULATE( [Sum_Gross_Sales], DATESBETWEEN( 'Calendar'[Date], TODAY() -7, TODAY() - 1) )