Time Granularity & Comparisons
#
GranularityThe granularity feature allows you to control the aggregation of time with your metric. We support daily, monthly, weekly, quarterly, and yearly. Selecting granularity will aggregate all values in that time window and present the relevant aggregation for the measure in the time window selected.
The default granularity that's applied to the metric is dependent on the primary time dimension of the data source that the metric is built upon, which supports day, week, month, quarter, year.
The granularity menu will hide options depending on the default granularity. For example, if the metric is monthly, we won't allow you to select weekly or daily granularity. Similarly, we won't allow the user to select various presets that are less than the metric's default granularity.
Details
- For weekly granularity, we use the ISO-standard default of Monday.
- For quarterly granularity, we will use the calendar quarter (ex: Q1 is January 1st to March 31st)
- For monthly, granularity, we use the calendar month (ex: January 1st to January 31st)
- For yearly granularity, we use the calendar year (ex: January 1, 2020, to December 31, 2020)
Trim and Untrim Toggle
Granularity by default trims incomplete time periods so there are no false trends displayed. This will also ensure that when time comparison is applied, it's only happening on complete ranges. As an example, if you select weekly granularity and the latest day of data occurs in the middle of the week, we will trim the output to return only the latest complete week.
If you would prefer the whole window of data, there is a toggle in the granularity menu that indicates whether you want to return untrimmed granularity. If you select untrim
as opposed to trim
(default), it will include the whole time period that's selected on the chart regardless of incomplete windows.
Filling Zeros
If there are any time periods without data when granularity is applied, we fill in a value of 0 for metrics that are based on measures that aggregate with a count or sum. For all other metric types we show a null value.
#
Time ComparisonTime comparison allows you to compare various time ranges and view a relative growth rate. We support Week over Week, Month Over Month, Quarter over Quarter, and Year over Year. To use time comparison, select a granularity first, followed by choosing a time comparison in the "Edit Chart" menu.
Time Comparison and Granularity
The time comparison functionality requires an input granularity first. Additionally, we will hide time comparison options that don't make sense for a given granularity, and vice versa. This means that the time comparison period must be greater than equal to the given granularity. For example, we won't show a week-over-week time comparison option if you've selected monthly granularity.
Calculation
We use the pandas pct_change
method to calculate time comparison, and then multiply the results by 100. For most values, the pct_change
method will calculate via this formula:
(Values in Period 2 - Values in Period 1) / Values in Period 1
But if there is no data in Period 1, pct_change
will resolve to infinity. In this case, we will show an infinity symbol on the chart. For more information, check out the pandas docs for the pct_change
method.