Forum Discussion
Complex Filtering with Dates
- Anonymous8 years ago
You need a date table. Use the date field in this table as a filter in your report and then use this measure:
Measure = VAR selectedDate = SELECTEDVALUE(Date[Date]) RETURN CALCULATE( COUNTROWS(EmployementRecord), FILTER(EmployementRecord, EmployementRecord[StartDate] <= selectedDate && (EmployementRecord[EndDate] >= selectedDate || ISBLANK(EmployementRecord[EndDate])) ) )
Hi danielgatley
There are a few things you can do.
You can add the 'date' field onto the report page, set it as a filter and use that as your 'day selection'.
You could create a flag column based on the same SQL code and set that to either 1 or 0 and use that as your filter/current day value.
Do you have examples of where you are with it all?
Thanks
Shebr
So I went back and looked at the data and decided to add a coulmn which takes EndDate and if null replaces it with the current date. Doing this I can apply page level filters to specify dates and this gives me the results i'm after, so the question is how do I give the power to the user. Given my filtering needs a single date value compare against two seperate columns (<= StartDate and >= EndDate) what is my best options for achieving this? I did test using two slicers based on the StartDate and EndDate fields and this works when they are both set to the same date but this isn't exactly easy to use.