week on week % change beast mode
date examples are based on writing today - 6th September.
my aim is to create a beastmode, which can ultimately be applied to any metric, which shows the week-on-week % change. this value would be able to be displayed in a table by date(week) or as a KPI card which would be filtered to show data for last week.
the goal is to have the working beastmode for the values which are pre-calculated in the 'period over period' cards. I have attached the vairance bar line example I use - I would like the variance %s shown here as a beastmode value.
example:
a = sum the complete last week revenue (e.g. 26th August - 1st September *Domo weeks run Sunday to Saturday)
b = sum the complete previous to last week revenue (e.g. 19th August - 25th August)
wow%change = sum(a) / sum(b) -1
e.g. 1500 / 1350 - 1 = 11.1%
I found some details on the domo knowledge board but cannot get the formula to work. I get a divide by zero error. example below...
(CASE
WHEN ((year(`activity_date`)=year(curdate())) AND (weekofyear(`activity_date`)=weekofyear(CURDATE())))
THEN `revenue`
END
/
CASE
WHEN (weekofyear(curdate())=1)
THEN (CASE WHEN ((year(`activity_date`)=(year(curdate()) - 1)) AND (weekofyear(`activity_date`)=52))
THEN `revenue` END )
ELSE (CASE WHEN ((year(`activity_date`)=year(curdate())) AND (weekofyear(`activity_date`)=(weekofyear(CURDATE()) -1)))
THEN `revenue` END )
END) -1
Comments
-
Hi @jonathanlooker, the reason you can get a divide by zero error is becuase you have division in your beast mode. A denominator can never equal 0, else Domo throws an error.
My suggestion is you take the entire denominator and apply a case statement up front if the denominator = 0 then the value will be 0. You numerators and denominators can contain additional case statements, you just need one that encompises the entire formula.
CASE WHEN Denominator = 0 THEN 0 ELSE
Numerator
/
Denominator
END
Thanks,
Josh
1 -
@jonathanlooker In addition to what @jstan said about adding a WHEN clause to prevent divide by zero errors, you have to make sure that the date range on your card is big enough to contain all data being compared. For example, if today (9/13/18) I am looking at data for last week Mon-Sun (9/3/18-9/9/18) vs the previous period (8/27/18-9/2/18), my card has to contain data from 8/27/18 and thereafter. Filtering the card for "last 22 days" or "last 3 weeks" should contain all of this data and then update automatically as you head into a new week.
1
Categories
- All Categories
- 1.9K Product Ideas
- 1.9K Ideas Exchange
- 1.6K Connect
- 1.3K Connectors
- 302 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 104 SQL DataFlows
- 637 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 762 Beast Mode
- 65 App Studio
- 42 Variables
- 704 Automate
- 182 Apps
- 458 APIs & Domo Developer
- 53 Workflows
- 11 DomoAI
- 39 Predict
- 16 Jupyter Workspaces
- 23 R & Python Tiles
- 401 Distribute
- 116 Domo Everywhere
- 277 Scheduled Reports
- 8 Software Integrations
- 133 Manage
- 130 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 12 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 111 Community Announcements
- 4.8K Archive