Forum Discussion
Problem with DATESBETWEEN that has a variable inside
- 1 year ago
This is a lot to take in 😀.
I would start by creating 2 measures to return the desired start and end dates based on the slicer selection. You can then put these into a table / matrix visual and see what they are returning, and you can also use them within the YTD calculation. That will allow you to determine where the underlying issue is - either the calculation of the dates, or applying those dates as filters.
Once you've identified the problematic code, post the definition of the measure and a screenshot of the model relationships, ideally highlighting tables which are used for slicers so that we can get an overall picture of what is going on.
Create a proper date table and mark it as a date table. There's plenty of videos and articles about how to do that if you're unsure.
Link the date table to any of the other tables which have date columns.
Create a new column in the date table for Season, probably calculated using the month number but using whatever business logic you need.
You can now use the date column in one slicer and the season column in the other. Everything should just work.