Forum Discussion
User Defined Date Range for a Calendar Table
Hi everyone,
Is there a way to dynamically contract/expand the date range of DAX calendar table based off a selected number?
So for example instead of:
Table = CALENDAR(TODAY()-30, TODAY())
I want:
Table = CALENDAR(TODAY()-[random variable number], TODAY())
Ultimately I am trying to filter a date slicer to display only dates relevant to specific days selected by the user (e.g. the last 7 days). I could create a separate relative date slicer, but the customer would prefer a slicer containing values such as 7, 14, 30, 90 days etc.
Best regards,
ImranAmi
3 Replies
- TomMartensSuper User
Hey imranami ,
basically it's not possible to re-calculate a table based on the input of a user. This is because tables that are created by DAX (this is also valid for tables that are created using Power Query) will be re-calculated only during data refresh.
But nevertheless, you can hide/unhide rows from the calendar table by using the visual level filter on slicers that has been introduced with the "June 2019" release of Power BI Desktop.
Here is the link to the release: https://powerbi.microsoft.com/de-de/blog/power-bi-desktop-june-2019-feature-summary/ and the the link to the more detailed feature: https://powerbi.microsoft.com/de-de/blog/power-bi-desktop-june-2019-feature-summary/#slicerFilters
And an awesome article b< Alberto Ferrari: https://www.sqlbi.com/articles/syncing-slicers-in-power-bi/
Regards,
Tom
- imranamiHelper I
Thanks Tom and for the links - this has saved me a lot of time.
What would be a good approach for applying a visual level filter to a date slicer based on the values in the table? For example if a user selects 7 from the list, the date range should only display a range of today day’s date minus 7 as the start date, and today’s date as the end date.
I have this working for all visuals, but not for the date slicer.
Best regards,
ImranAmi
- imranamiHelper I
Hi everyone - any feedback on the question above would be appreciated.