Intro
This article lists a number of period-over-period calculations you can try out in Beast Mode. Many of these same calculations may also be possible using our Period-over-Period charting functionality.Creating a Period-over-Period Graph
You can create a period-over-period graph in Domo using one Beast Mode calculation for the x-axis (date) and another Beast Mode calculation for the series. You can also create a Beast Mode calculation to limit the date ranges shown on the card. Start creating your own period-over-period Beast Mode calculations using the samples provided below. The following examples show you how to create a year-over-year graph as a demonstration. Step 1: Create the x-axis (date) calculation (REQUIRED) In this step you project the dates from previous periods, such as years, onto the current period. In this way, data from different periods will appear on the same range on the x-axis. This Beast Mode calculation replaces the year in a date value with the current year.STR_TO_DATE(CONCAT(YEAR(CURRENT_DATE()), '-', DATE_FORMAT(`Date_Field`, '%m-%d') ), '%Y-%m-%d')
Step 2: Create the series (year) calculation (REQUIRED)
Next you create a series that represents each period’s data. This Beast Mode calculation lets you create a series that represents the data for each year.
YEAR(`Date_Field`)
Step 3: Create calculations for filtering (OPTIONAL)
If you want to see a time frame besides a full year (quarter-over-quarter, month-over-month, etc.), you can create a filter that allows you to get just the date range or period you’re interested in.
There are two different methods for creating Beast Mode calculations for filtering. The first method lets you create a filter for a specific date range. The second method lets you create a filter for a specified number of previous days, months, etc.
Specific Date Range
Use this Beast Mode calculation to create a filter for a specific date range.
Calculating Week-over-Week Change
Use the following code to create a calculation that shows week-over-week change. The following example includes 4 weeks prior (aligned on days), and 52 weeks prior (aligned on days). Change the values to the time periods you want. X Axis is Date - has to be “Common Date”:Calculating Percent Change from the Previous Year to the Current Year
Say you have a card that shows the last 24 months, grouped by month. You have the year set as the series. In the summary number you want to show the percent change from January through the current month of the previous year compared to January through the current month of the current year. To achieve this, you can create the following Beast Mode calculation:(This Year’s Value – Last Year’s Value) / Last Year’s Value
Calculating Variance
Variance CY-PY
Use the following code to create a calculation for the variance Current Year - Past Year:Variance % ((CY - PY)/PY)
Use the following code to create a calculation for the variance % ((Current Year - Past Year) / Past Year):Year-to-Date Variance
Let’s say you have a DataSet with your employee count by store by month. How could you compare the current month’s employee count to the year-end count? Assuming your card is filtered to the current year, you could create the following Beast Mode calculations: Employee Count This Month:COUNT(DISTINCT CASE WHEN YEAR(DateColumn) = YEAR(CURRENT_DATE()) AND MONTH(DateColumn) = MONTH(CURRENT_DATE()) THEN `Employee ID` END)
Employee Count This Year:
COUNT(DISTINCT'Employee ID')
Employee Count This Year - Employee Count This Month (YTD Variance):
COUNT(DISTINCT `Employee Id` - COUNT(DISTINCT CASE WHEN YEAR(DateColumn) = YEAR(CURRENT_DATE()) AND MONTH(DateColumn) = MONTH(CURRENT_DATE()) THEN `Employee ID` END)
If you need this data to be trended over time, this solution will require doing some DataFlow work to summarize things at a monthly level with a reference to YTD for each month.
Calculating Year-over-Year (YOY) with Ratios
All calculations for ratios must be done in a DataFlow if using this type of comparison.YOY: Multi-Period Comparison
To create multi-period year-over-year calculations, refer to the following table:| Period | Description | Calculation |
|---|---|---|
| By Year | Create a year Beast Mode and plot as category (x-axis on most charts). | year( |
| By Quarter | Create a Quarter Beast Mode and plot as category (x-axis on most charts), and if you’re spanning multiple years, use year( ) as the series. | Quarter( |
| By Month | Create a Month Beast Mode and plot as category (x-axis on most charts), and if you’re spanning multiple years, use year( as the series. | Month( |
| By Week | Create a Week Beast Mode and plot as category (x-axis on most charts), and if you’re spanning multiple years, use year( as the series. | WeekofYear( |
| By Day | Create a Day Beast Mode and plot as category (x-axis on most charts), and if you’re spanning multiple years, use year( as the series. | DayofYear( |
YOY: 2-Period Comparison
‘This Year’ and ‘Last Year’ can be swapped out for other text or amount fields. When running ratios, amount fields are needed.
The advantage of using the “Same Series” vs. the “Multiple Series” is that you can consolidate the code using the “Same Series”. However, if you’re swapping out ‘This Year’/‘Last Year’ for amount columns, these need to be separated.
YOY: Full-Year Comparison
To create full-year year-over-year calculations, refer to the following table:| Type | Calculation |
|---|---|
| Multiple Series - Current Year | Case when Year( |
| Multiple Series - Previous Year | Case when Year( |
| Multiple Series - Same Series | Case year( |
| Ratio: % change between the two using the formula (C/P) - 1 |
|
YOY: Year-to-Date (YTD) Comparison
To create year-to-date year-over-year calculations, refer to the following table:| Type | Calculation |
|---|---|
| Multiple Series - Current Year | CASE WHEN year( |
| Multiple Series - Previous Year | CASE WHEN ((year( |
| Multiple Series - Same Series | CASE WHEN year( |
| Ratio: % change between the two using the formula (C/P) - 1 |
|
YOY: Quarter Comparison
To create quarterly year-over-year calculations, refer to the following table:| Type | Calculation |
|---|---|
| Multiple Series - Current Year | Case when (quarter( |
| Multiple Series - Previous Year | Case when (quarter( |
| Multiple Series - Same Series | Case when (Quarter( |
| Ratio: % change between the two using the formula (C/P) - 1 |
|
YOY: Quarter-to-Date (QTD) Comparison
To create quarter-to-date year-over-year calculations, refer to the following table:| Type | Calculation |
|---|---|
| Multiple Series - Current Year | Case when (quarter( |
| Multiple Series - Previous Year | Case when (quarter( |
| Multiple Series - Same Series | Case when (Quarter( |
| Ratio: % change between the two using the formula (C/P) - 1 |
|
YOY: Month Comparison
To create monthly year-over-year calculations, refer to the following table:| Type | Calculation |
|---|---|
| Multiple Series - Current Year | Case when (month( |
| Multiple Series - Previous Year | Case when (month( |
| Multiple Series - Same Series | Case when (month( |
| Ratio: % change between the two using the formula (C/P) - 1 |
|
YOY: Month-to-Date (MTD) Comparison
To create month-to-date year-over-year calculations, refer to the following table:| Type | Calculation |
|---|---|
| Multiple Series - Current Year | Case when (month( |
| Multiple Series - Previous Year | Case when (month( |
| Multiple Series - Same Series | Case when (month( |
| Ratio: % change between the two using the formula (C/P) - 1 |
|
YOY: Week Comparison
To create month-to-date year-over-year calculations, refer to the following table:| Type | Calculation |
|---|---|
| Multiple Series - Current Year | Case when (WEEKOFYEAR( |
| Multiple Series - Previous Year | Case when (WEEKOFYEAR( |
| Multiple Series - Same Series | Case when (WEEKOFYEAR( |
| Ratio: % change between the two using the formula (C/P) - 1 |
|
YOY: Week-to-Date (WTD) Comparison
To create week-to-date year-over-year calculations, refer to the following table:| Type | Calculation |
|---|---|
| Multiple Series - Current Year | Case when (WEEKOFYEAR( |
| Multiple Series - Previous Year | Case when (WEEKOFYEAR( |
| Multiple Series - Same Series | Case when (WEEKOFYEAR( |
| Ratio: % change between the two using the formula (C/P) - 1 |
|
YOY: Day Comparison
To create week-to-date year-over-year calculations, refer to the following table:| Type | Calculation |
|---|---|
| Multiple Series - Current Year | Case when (DAYOFYEAR( |
| Multiple Series - Previous Year | Case when (DAYOFYEAR( |
| Multiple Series - Same Series | Case when (DAYOFYEAR( |
| Ratio: % change between the two using the formula (C/P) - 1 |
|
POP Calculations with Ratio Calculations (Current Period vs. Last)
POP: Quarter-over-Quarter (QOQ) Comparison
To create quarter-over-quarter comparison calculations, refer to the following table:| Type | Calculation |
|---|---|
| Multiple Series - Current Period | CASE WHEN ((year( |
| Multiple Series - Previous Period | CASE WHEN (quarter(curdate())=1) THEN (CASE WHEN ((year( |
| Ratio: % change between the two using the formula (C/P) - 1 |
|
POP: QTD Quarter-over-Quarter Comparison
To create quarter-to-date quarter-over-quarter comparison calculations, refer to the following table:| Type | Calculation |
|---|---|
| Multiple Series - Current Period | CASE WHEN ((year( |
| Multiple Series - Previous Period |
|
| Ratio: % change between the two using the formula (C/P) - 1 | Take the formula above and insert the previous two sections to get the result. |
POP: Month-over-Month (MOM) Comparison
To create month-over-month comparison calculations, refer to the following table:| Type | Calculation |
|---|---|
| Multiple Series |
|
| Ratio: % change between the two using the formula (C/P) - 1 |
|
POP: Month-to-Date MOM Comparison
To create month-to-date month-over-month comparison calculations, refer to the following table:| Type | Calculation |
|---|---|
| Multiple Series |
|
| Ratio: % change between the two using the formula (C/P) - 1 |
|
POP: Week-over-Week (WOW) Comparison
To create week-over-week comparison calculations, refer to the following table:| Type | Calculation |
|---|---|
| Multiple Series |
|
| Ratio: % change between the two using the formula (C/P) - 1 |
|
POP: Week-to-Date WOW Comparison
To create week-to-date week-over-week comparison calculations, refer to the following table:| Type | Calculation |
|---|---|
| Multiple Series |
|
| Ratio: % change between the two using the formula (C/P) - 1 |
|
POP: Day-over-Day (DOD) Comparison
To create day-over-day comparison calculations, refer to the following table:| Type | Calculation |
|---|---|
| Multiple Series |
|
| Ratio: % change between the two using the formula (C/P) - 1 |
|