Working with Date Variables

Chartio's relative date variables allow you to generate a custom date that can be used anywhere you would enter a date value.

For an overview of Relative Date Variables, see our documentation.

Examples

Interactive Mode filtering

Create a chart to compare this calendar week's sales to the previous calendar week.

Our first layer uses the "current week" filter to get the sum of payments for the current week.

Our second layer uses relative date variables to filter by the previous calendar week.

To recreate the chart above, select Union as the Merge type, check the Add Layer Names checkbox, and select a Bar chart as your chart type.

In the Data Pipeline

We want to filter out the current month from our chart data. Because we're using multiple layers, it's easiest to do this in the Data Pipeline with a Filter step. Our chart dates are grouped by month, so we need to use the BUCKET function to return the month and year of the current month.

Dashboard filter defaults

We want our calendar filter to default to the previous month, so we'll use the following for the default start and end dates:

{CURRENT_MONTH.START.SUB(1, 'month')}
{CURRENT_MONTH.END.SUB(1, 'month')}