I need a beast mode that provides 2025 Sales % VS 2025 targets

2025 targets are based on 2024 sales up to todays date multiplied by a growth rate. For product category 1 the growth rate is 5.5% and for product category 2 it is 14.5%. Sales are recorded in the column 'Extended Amount' and date is determined by column 'TRX Date'. I currently have the below Beast mode but it is returning an error. Could someone please advise where I might be going wrong.
(CASE when YEAR(trx_date
)='2025' then extended_amount
else 0 End) /
CASE
WHEN Product Category
LIKE 'Product 1%' THEN
sum((CASE WHEN ((Year(trx_date
) = Year(DATE_SUB(Current_Date(),INTERVAL 1 Year))) AND (DAYOFYEAR(trx_date
) <= DAYOFYEAR(Current_Date()))) THEN extended_amount
* 1.055 ELSE 0 END ))
ELSE sum((CASE WHEN ((Year(trx_date
) = Year(DATE_SUB(Current_Date(),INTERVAL 1 Year))) AND (DAYOFYEAR(trx_date
) <= DAYOFYEAR(Current_Date()))) THEN extended_amount
* 1.145 ELSE 0 END ))
END
Best Answer
-
@CK_16 The error can be resolved by rearranging the calculation so that the numerator and denominator of your beast mode each contain a single case statement within a sum like below.
sum(case when year(`trx_date`) = 2025 then `extended_amount` else 0 end) / sum( case when `Product Category` like 'Product 1%' and year(`trx_date`) = year(current_date()) - 1 and dayofyear(`trx_date`) ⇐ dayofyear(current_date()) then `extended_amount`*1.055 when year(`trx_date`) = year(current_date()) - 1 and dayofyear(`trx_date`) ⇐ dayofyear(current_date()) then `extended_amount`*1.145 else 0 end)
1
Answers
-
@CK_16 The error can be resolved by rearranging the calculation so that the numerator and denominator of your beast mode each contain a single case statement within a sum like below.
sum(case when year(`trx_date`) = 2025 then `extended_amount` else 0 end) / sum( case when `Product Category` like 'Product 1%' and year(`trx_date`) = year(current_date()) - 1 and dayofyear(`trx_date`) ⇐ dayofyear(current_date()) then `extended_amount`*1.055 when year(`trx_date`) = year(current_date()) - 1 and dayofyear(`trx_date`) ⇐ dayofyear(current_date()) then `extended_amount`*1.145 else 0 end)
1 -
That works now thank you so much for your help Michelle!
0
Categories
- All Categories
- Product Ideas
- 2.1K Ideas Exchange
- Connect
- 1.3K Connectors
- 309 Workbench
- 7 Cloud Amplifier
- 10 Federated
- Transform
- 665 Datasets
- 120 SQL DataFlows
- 2.3K Magic ETL
- 825 Beast Mode
- Visualize
- 2.6K Charting
- 90 App Studio
- 46 Variables
- Automate
- 197 Apps
- 489 APIs & Domo Developer
- 94 Workflows
- 24 Code Engine
- AI and Machine Learning
- 23 AI Chat
- 4 AI Projects and Models
- 18 Jupyter Workspaces
- Distribute
- 119 Domo Everywhere
- 283 Scheduled Reports
- 11 Software Integrations
- Manage
- 145 Governance & Security
- 12 Domo Community Gallery
- 49 Product Releases
- 13 Domo University
- Community Forums
- 41 Getting Started
- 31 Community Member Introductions
- 116 Community Announcements
- 5K Archive