Date & History Modifiers
A guide on how to use the date and history modifiers to return data from another date field or a different time period.
All data functions in the formula editor allow adding modifiers. The modifiers give advanced functionality to the formulas in Plecto as they tell the formulas to look at data from another date field or from a different time period. These modifiers are:
- Date modifier. The date modifier allows changing the date field used in formulas. For example, if the default date in a data source is "Created date," but you want the formula to look at "Closed date" instead, you can use a date modifier.
- History modifier. The history modifier allows the formula to include data from another time period outside of what you can select on widgets, reports, notifications, or other places where formulas are used. It makes the formula look at data relative to a time period in the past, for example, the previous 5 days, 2 weeks before the beginning of the current month, and more. You can also use it to compare your current metrics to those from another time period.
Know the default date in your data source
The default date serves as a point of reference for Plecto for looking at your data. For integrations, the default date can be changed in the data source settings. If you are using manual data sources, the default date is usually the "Created date."
Use the date modifier to make formulas look for information based on another date field in your data source than the default date. For most manual data sources, the default date is the "Created date." To see the default date of your integration data source, go to Data management > Data sources, open the data source settings and look for a field called "Default date used in formulas."
Let's say you want to display the total value of sales deals with the status "won" that are closed within the current month (September). Knowing that the default date in the data source below is "Created date," a formula summing the value of won deals would return 0, because the registrations were created in the previous month (August).
An example of a data source with two different date fields, namely "Created date" and "Closed date." The "Created date" field is the default date field in this data source.
However, if we change the date field in the formula editor, it will shift the formula's focus to search for values based on the "Closed date" field instead and display 1320 as required. The formula would look like the following.
In this example, the date modifier is necessary because it enables Plecto to generate the right metrics. Here is an example of how to add a date modifier to data function components in the formula editor:
The history modifier manipulates the formula to include data from a time period in the past, outside of what you can select on widgets, reports, notifications, or other places where formulas are used. With history modifier, you can see your metrics for the previous 5 days, 2 weeks before the beginning of the current month, same month last year, and more. The available time periods are Day(s), Week(s), Month(s), Year(s).
The history modifier enables Plecto to display metrics based on different time periods on a single dashboard widget. It is common to use formulas with history modifiers on widgets that can display at least two KPIs, such as the number box, speedometer, line and area charts, and the table widget.
An example of a number box displaying data for the current week compared to last week.
Imagine you want to count the number of sales deals for the past* 5 days from a data source called "Deals." The formula would look like the following:
*The "past" period is relative to the time period selected on a widget or feature. Let's break down how a dashboard widget would display data from the formula above if different time periods are selected.
- Current day: The widget will display data from five days back, starting from yesterday. For example, if the current day is June 10th, it will show data from the 5th until the 9th of June (both days included).
- Current week: The widget will display data from five days back, starting from the last day of the previous week. For example, if the current day is June 10th and the week starts on June 7th, the widget will show data from the 2nd until the 6th of June (both days included).
- Current month: The widget will display data from five days back, starting from the last day of the previous month. For example, if the current day is June 10th, it will show data from the 27th until the 31st of May (both days included).
- Current year: The widget will display data from five days back, starting from the last day of the previous year. For example, if the current year is 2021, the widget will show data from the 27th until the 31st of December 2020 (both days included).
Tip: Give clear titles to your widgets
If you apply history modifiers to your formulas, Plecto will show other metrics than what is indicated in the time period display (current day, current week, etc.). Therefore, we recommend you to give your widgets clear titles that best describe the displayed data, for example, "Number of Deals vs. Previous Month."