Forum Discussion
Help needed with filters
- 4 years ago
Perhaps the FILTER is being called before the REMOVEFILTERS is applied. Try
TTM Hires = VAR selecteddate = MAX ( 'Date'[Date] ) VAR enddate = DATEADD ( LASTDATE ( 'Date'[Date] ), -1, YEAR ) RETURN CALCULATE ( DISTINCTCOUNT ( 'Monthly Workforce'[FDS ID] ), REMOVEFILTERS ( 'Date' ), 'Monthly Workforce'[Hire Date] <= selecteddate && 'Monthly Workforce'[Hire Date] > enddate )
Try changing the REMOVEFILTERS('Date'[Date]) to REMOVEFILTERS('Date'), so that filters on any column in the date table are removed. Its common with date tables for other filter columns to be added behind the scenes, e.g. a month sort order column.
This really has me puzzled. I am quite the beginner when it comes to DAX - but I thought what I was doing might work 😋
Thank you - but the change did not work.
I was able to get the correct answer by creating a calculated table that summarizes the Workforce table by month and then filtering for the needed timeframe. But I am really curious as to why I can't get the other formula to work.
- johnt754 years ago
Super User
Perhaps the FILTER is being called before the REMOVEFILTERS is applied. Try
TTM Hires = VAR selecteddate = MAX ( 'Date'[Date] ) VAR enddate = DATEADD ( LASTDATE ( 'Date'[Date] ), -1, YEAR ) RETURN CALCULATE ( DISTINCTCOUNT ( 'Monthly Workforce'[FDS ID] ), REMOVEFILTERS ( 'Date' ), 'Monthly Workforce'[Hire Date] <= selecteddate && 'Monthly Workforce'[Hire Date] > enddate )- Anonymous4 years agoNot applicable
Thank you so much. This is such a long journey. (Learning DAX)
- johnt754 years ago
Super User
If you can, take the SQL BI guys course on DAX, and definitely check them out on YouTube.
Enjoy DAX!