Intro
This article answers frequently asked questions about Beast Mode calculations.How do I get started with Beast Mode? For detailed information about adding calculations using Beast Mode, see Beast Mode Functions Reference Guide. Can I certify a Beast Mode? No. Why am I getting an “Invalid Query” error when I try to save my Beast Mode calculation? Here are some common reasons why you might have received an Invalid Query error as a result of improper practices in setting up a Beast Mode:
- Column names need to be surrounded by back tics:
`column`. Users commonly use single quote marks instead of the back tic, and this creates the error. - A string value needs to be surrounded by single quotes:
‘text’. - A case statement always needs to have a
CASE,WHEN,THEN, and anEND.Here is an example of a basic case statement:
CASE WHEN `column1` = ‘good’ THEN ‘Yes’ ELSE ‘No’END
TheELSEportion is optional; if there is noELSEthen the value will beNULLif it doesn’t match the first portion.
case when `Name` like 'Ca%' AND `id` < 10 then 0 else 1 end
Can I create custom or multiple summary numbers using Beast Mode?
Yes. For information and examples, see Sample Beast Mode Calculations — Creating a custom summary number.
Can I do “value summing” within Beast Mode?
Yes, this is possible. For example:
DATEDIFF function then subtract 2 for every week.
How do I filter data so the summary number matches the value displayed in the card?
Say you have a map card of the United States that calculates the sales amount broken out by state, and the summary number shows the total sales amount. However, the total sales amount in the card legend for the United States is lower than the summary number amount. The reason the sales amount in the Summary Number is larger is because the summary number takes into account all sales amounts regardless of country, and the card legend only shows the sales amounts for the United States. For this scenario, you will need to create a Beast Mode calculation that filters out the non-United States sales amounts.
The Beast Mode to do this would look like this:
- In Analyzer, open Chart Properties.
- In Data Label Settings, enter
%_PERCENT_OF_TOTALin the Text field.
- Set your date grain to “by Quarter” at the top of the card. For more information, see Adding Filters to Your Chart.
- Add your date and value columns to the x- and y-axis, respectively. For more information, see Applying DataSet Columns to Your Chart.
- Set your aggregation option for your value column to AVG.
- Using a subquery to retrieve the sum of the last 3 months’ worth of values,
- Dividing them by the number of records it found in that range, and
- Calling the field the “Rolling_Average” field.
CASE statement to create a calculation, you may want to aggregate the results of this CASE statement. Unfortunately, many users make the mistake of using a SUM function inside of the CASE statement:
CASE statement as a Summary Number. For a value to be used as a Summary Number, that value must have a numeric data type. So if a calculation contains only a CASE statement, it will be seen by Domo as a string data type rather than a numeric data type.
The solution to adjusting a common CASE statement calculation into a field with a numeric data type is identical to our solution for conditional summing. Simply “wrap” the entire statement in an aggregation function, such as SUM or COUNT, like so:
-
A calculation named “Months” that formats the dates on the x-axis so it shows just the month and not the year:
DATE_FORMAT(`DateColumn`,'%M') -
A calculation named “Year over Year” that creates a series in which values are broken out by year:
YEAR(`DateColumn`) -
A calculation named “Month Sort” that sorts the months on the x-axis:
MONTH(`DateColumn`)
STR_TO_DATE(`DateColumn`,’%d/%m/%Y’)
Note: Be sure only date values, such as 1/1/2016, are used as values in the column. Otherwise, the calculation won’t work.
DATE_FORMAT(`DateColumn`,’%d-%m’)
You can also format dates in using Chart Properties. For more information, see Changing the Date Format in Your Chart.
How do I change the date column to represent a different time zone?
You can adjust your company time zone in the Admin Settings, as described here: Setting Your Company Time Zone.
Sometimes, though, you’ll need to use a Beast Mode when time zones don’t match up between DataSets.
Say the dates in the date column in a card are based on EST, but your company is based on PST, and you want to see the data based on PST instead of EST. You can shift the dates values to another time zone by adding or subtracting time from the date values depending on what time zone you are switching it to. The functions that add and subtract time are DATE_ADD() and DATE_SUB(). For example, switching the date values from EST to PST would require you to subtract 3 hours, and can be done with the Beast Mode calculation like the one below:
DATE_SUB(`DateColumn`, interval 3 HOUR)
How can I use Beast Mode to calculate percent (%) change from the previous year to the current year?
This topic is discussed here: Sample Beast Mode Calculations - Calculating Percent Change from the Previous Year to the Current Year.
How do I create a period-over-period graph using Beast Mode?
This topic is discussed here: Sample Beast Mode Calculations - Creating a Period-over-Period Graph.
How do I divide by NULL or zero?
You can divide by NULL or zero by using the following case statement:
CASE WHEN `Column_1` = 'Value_1’ THEN SUM(`Column_1`) END
Instead, you need to “wrap” the entire statement in a SUM function for it to execute properly:
SUM(CASE WHEN `Column_1` = 'Value_1’ THEN SUM(`Column_1`) END)
I’ve added a shared calculation but it only seems to show up in new cards. Is there a way to use it in existing cards?
When you share a Beast Mode calculation, it is stored on the data source powering the card. The shared calculation is available in other cards that are powered up by that same data source.
What do I do if my Beast Mode “disappears” after saving?
This issue is most commonly caused by multiple users editing the same card at the same time and overwriting each others’ changes. If the Beast Mode is shared on the DataSet, it can also be caused by users editing different cards on the DataSet overwriting each others’ changes to the shared Beast Modes on that DataSet.
This problem can most easily be solved by e
ither coordinating with other users to make sure you’re not overwriting each others’ changes, or by editing at a time when others are not as likely to also be making edits.
This issue also occurs when you attempt to create Beast Mode calculations on a card in a drill path. Because drill path cards are not actual cards, Beast Mode calculations created in a drill path will not be saved. In order to ensure the calculations are saved, they must be created in the top layer of the card and have the Share Calculation on DataSet checkbox checked. For more information about drill path, see Adding Drill Path to Your Chart
.
How do I deal with NULL values when adding columns?
If you are trying to SUM the values in a column with NULL values, you need to convert those NULL values to zero using the IFNULL function.
For example,
IFNULL(`col`,0)
So let’s say you had a “Category” column with values “A,” “B,” and “C,” and an “Amount” column with values “20,” “10” and an empty cell (which is NULL). When you SUM the Amount column, the IFNULL calculation converts the NULL value to 0 and then applies the SUM as normal.
Can I use links to local file URLs in Beast Mode calculations?
Not at this time.
How does the WEEKDAY function work in Beast Mode?
The WEEKDAY function is not supported in Beast Mode. If WEEKDAY is used, it is replaced with the functionality of DAYOFWEEK.
Why can’t I delete a Beast Mode calculation from a card?
When a Beast Mode calculation is shared on a DataSet, it can be used on multiple cards. If the calculation is being used in any of those cards (filter, series, sort, date column, etc.), it can’t be deleted until the calculation is no longer being used by any cards. If you try to remove that calculation, you will get an error message listing all of the cards using the calculation. You should also check the drill paths on each card, as they may be hiding calculations that you aren’t aware are being used.
Why does multiplying two large positive numbers result in a negative number?
Numeric columns are either 64 bit LONG, 64 bit FIXED DECIMAL, or FLOAT (DECIMAL vs DOUBLE) datatypes. When a mathematical function results in a numerical value larger than maximum for the datatype, then it will overflow to a negative number.
Can I use Beast Mode calculations in Domo Bricks?
Yes, you can use Beast Mode calculations in Domo Bricks. Remember the following:
- You must save the Beast Mode calculation to the DataSet.
- The query must include the parameter “useBeastMode=true”.
- When you refer to a Beast Mode calculation in the query, refer to it by its ID (Format: calculation_ac6f2ae5-a1a3-4eac-b7e6-cff4c0a9ed2d). If the calculation is aliased, you can refer to it by its alias in the query in the returned result set.
- You can find Beast Mode calculation aliases using the Beast Mode report in the Domo Governance connector.
- If the Beast Mode calculation is aggregated, then the aggregation statement can be left out of the query.
- If the Beast Mode calculation is not aggregated, the aggregation statement must be included in the query.