Creating Dynamic Dashboards: Filtering Data for 3 Months Before and After Today
To configure a relative date filter for a dashboard that includes all dates from 3 months before to 3 months after the current date, follow these steps:
Step 1: Create Dashboard Parameters
Set up two parameters:
- Parameter 1: Represents the last 3 months.
- Parameter 2: Represents the next 3 months.
Ensure the data type is set to “Date” and the selection type is “Range.” Use the Custom option to define the relative range for each parameter. For example:
-
For Parameter 1: Add a range to include the last 3 months.
-
For Parameter 2: Add a range to include the next 3 months.
Step 2: Apply the Dashboard Parameters in Code View Mode
In the code view of the dashboard, reference the parameters to filter your data based on the date range.
Sample Query:
SELECT *
FROM [DataSource]
WHERE [DateColumn] BETWEEN @{{:Parameter1.START}} AND @{{:Parameter2.END}}
Step 3: Preview and Validate
Verify that the parameters are correctly filtering data for the relative date ranges. Adjust as necessary based on the dashboard’s requirements.
This approach ensures that your dashboard dynamically adjusts to display data for the last 3 months and the next 3 months.