YOY calculations
I saw this post https://dojo.domo.com/t5/Domo-Dojo-Contest-January-2016/quot-Best-Beast-Mode-Formula-quot-Year-over-Year-Change/idi-p/7933
since I was having difficulty with Period over periods. Although useful it only works if you have the data range to select both years worth of data.
I am trying to just isolate a week and have a YOY% comparison for a certain dimension column with values
that existed a year ago but in my card I will only want to see the values for in 2016 with a column YOY%
Best Answer
-
It looks like at least one problem is with the date field in your second week function, highlighted in red. Those should be back-ticks (`) and not single quotes. Please test that and let me know if it works. If there still is a problem I will often just test one simpler part of the formula to ensure that works and then go on to the rest.
(
(SUM(CASE WHEN (YEAR(`Date`)) = YEAR(CURRENT_DATE()) and WEEK('Date') = WEEK(CURDATE()) THEN `Revenue` ELSE 0 END))
-
(SUM(CASE WHEN (DATE_FORMAT(`Date`,'%m/%d')) >= (DATE_FORMAT((CURRENT_DATE()),'%m/%d')) THEN 0 WHEN (YEAR(`Date`)) = (YEAR(CURRENT_DATE())-1) AND WEEK('Date') = WEEK(CURDATE()) THEN `Revenue` ELSE 0 END))/
(SUM(CASE WHEN (DATE_FORMAT(`Date`,'%m/%d')) > (DATE_FORMAT((CURRENT_DATE()),'%m/%d')) THEN 0 WHEN (YEAR(`Date`)) = (YEAR(CURRENT_DATE())-1) AND WEEK('Date') = WEEK(CURDATE()) THEN `Revenue` ELSE 0 END))I work for Domo.
**Say "Thanks" by clicking the thumbs up in the post that helped you.
**Please mark the post that solves your problem as "Accepted Solution"1
Answers
-
Hi -- Are you trying to compare the current week's performance, with the same week last year? If so, there is a "Week" function that will show you the week number of the year 0-52.
The syntax for current year would be:
case when year(`Date`) = year(curdate()) and Week(`Date`) = week(curdate()) then `Amount` else 0 End
The syntax for prior year would be:
case when year(`Date`) = year(curdate()) -1 and Week(`Date`) = week(curdate()) then `Amount` else 0 End
Can you clarify if that is what you need? Thanks,
I work for Domo.
**Say "Thanks" by clicking the thumbs up in the post that helped you.
**Please mark the post that solves your problem as "Accepted Solution"1 -
ke I am Looks like I am hitting an syntax error
(
(SUM(CASE WHEN (YEAR(`Date`)) = YEAR(CURRENT_DATE()) and WEEK('Date') = WEEK(CURDATE()) THEN `Revenue` ELSE 0 END))
-
(SUM(CASE WHEN (DATE_FORMAT(`Date`,'%m/%d')) >= (DATE_FORMAT((CURRENT_DATE()),'%m/%d')) THEN 0 WHEN (YEAR(`Date`)) = (YEAR(CURRENT_DATE())-1) AND WEEK('Date') = WEEK(CURDATE()) THEN `Revenue` ELSE 0 END))/
(SUM(CASE WHEN (DATE_FORMAT(`Date`,'%m/%d')) > (DATE_FORMAT((CURRENT_DATE()),'%m/%d')) THEN 0 WHEN (YEAR(`Date`)) = (YEAR(CURRENT_DATE())-1) AND WEEK('Date') = WEEK(CURDATE()) THEN `Revenue` ELSE 0 END))I don't see WEEK in purple
Thanks! Appreciate it!
0 -
It looks like at least one problem is with the date field in your second week function, highlighted in red. Those should be back-ticks (`) and not single quotes. Please test that and let me know if it works. If there still is a problem I will often just test one simpler part of the formula to ensure that works and then go on to the rest.
(
(SUM(CASE WHEN (YEAR(`Date`)) = YEAR(CURRENT_DATE()) and WEEK('Date') = WEEK(CURDATE()) THEN `Revenue` ELSE 0 END))
-
(SUM(CASE WHEN (DATE_FORMAT(`Date`,'%m/%d')) >= (DATE_FORMAT((CURRENT_DATE()),'%m/%d')) THEN 0 WHEN (YEAR(`Date`)) = (YEAR(CURRENT_DATE())-1) AND WEEK('Date') = WEEK(CURDATE()) THEN `Revenue` ELSE 0 END))/
(SUM(CASE WHEN (DATE_FORMAT(`Date`,'%m/%d')) > (DATE_FORMAT((CURRENT_DATE()),'%m/%d')) THEN 0 WHEN (YEAR(`Date`)) = (YEAR(CURRENT_DATE())-1) AND WEEK('Date') = WEEK(CURDATE()) THEN `Revenue` ELSE 0 END))I work for Domo.
**Say "Thanks" by clicking the thumbs up in the post that helped you.
**Please mark the post that solves your problem as "Accepted Solution"1
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.5K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 8 Federated
- 2.9K Transform
- 100 SQL DataFlows
- 616 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 738 Beast Mode
- 57 App Studio
- 40 Variables
- 685 Automate
- 176 Apps
- 452 APIs & Domo Developer
- 47 Workflows
- 10 DomoAI
- 36 Predict
- 15 Jupyter Workspaces
- 21 R & Python Tiles
- 394 Distribute
- 113 Domo Everywhere
- 275 Scheduled Reports
- 6 Software Integrations
- 124 Manage
- 121 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 108 Community Announcements
- 4.8K Archive