Case Statement with YTD
Hi Folks,
I'm trying to derive this through Beast mode calculation.
Requirement: Case statement
Score 1  If my error % is 0  75%
Score 2  If my error % is 75.1%  95%
Score 3  If my error % is 95.1%  100% (Includes 100)
Score 4  If my error % is 100% (YTD)
Finding difficulty in writing a case statement for 'Score 4'.
Date fields are (Month and Year)
Question:
When a person's error % for March 2023 is 100% but for Jan and Feb its less than 100% then the score should be 3 when filtered to March.
If the person's error % is 100% for all months YTD then it the score should be 4 (Fixed).
Any help on how to derive this using beast mode please?
The calculation that I tried and didn't work is
Best Answers

@Rupak Instead of using a fixed function, you can add a case statement within your sums to find the current year totals like this:
when sum(case when `Year` = YEAR(CURRENT_DATE()) then `Count Yes` end) / sum(case when `Year` = YEAR(CURRENT_DATE()) then `Count Overall` end) > 0.99 then 4
0 
What does your data look like and what kind of card are you outputting your result to? On your approach, you're only fixing by
Year
but if your data is meant to be broken down by person as well, you'll also need to include that in your fix function (otherwise it'll be the fixed of the entire universe and not for each person). I'd attempt changing the 3rd case statement to and move that as the first statement. Also does your data spans across multiple years and you're choosing which year to display? If so you won't be able to use the CURRENT_DATE() for the Beast Mode and would need to attempt a different approach.WHEN SUM(SUM(CASE WHEN `Year` = YEAR(CURRENT_DATE()) THEN `Count Yes` END) FIXED (BY `Person`))/SUM(SUM(CASE WHEN `Count Overall` = YEAR(CURRENT_DATE()) THEN `Count Yes` END) FIXED (BY `Person`)) = 1 THEN 4
0
Answers

@Rupak Instead of using a fixed function, you can add a case statement within your sums to find the current year totals like this:
when sum(case when `Year` = YEAR(CURRENT_DATE()) then `Count Yes` end) / sum(case when `Year` = YEAR(CURRENT_DATE()) then `Count Overall` end) > 0.99 then 4
0 
What does your data look like and what kind of card are you outputting your result to? On your approach, you're only fixing by
Year
but if your data is meant to be broken down by person as well, you'll also need to include that in your fix function (otherwise it'll be the fixed of the entire universe and not for each person). I'd attempt changing the 3rd case statement to and move that as the first statement. Also does your data spans across multiple years and you're choosing which year to display? If so you won't be able to use the CURRENT_DATE() for the Beast Mode and would need to attempt a different approach.WHEN SUM(SUM(CASE WHEN `Year` = YEAR(CURRENT_DATE()) THEN `Count Yes` END) FIXED (BY `Person`))/SUM(SUM(CASE WHEN `Count Overall` = YEAR(CURRENT_DATE()) THEN `Count Yes` END) FIXED (BY `Person`)) = 1 THEN 4
0
Categories
 All Categories
 1.5K Product Ideas
 1.5K Ideas Exchange
 1.4K Connect
 1.1K Connectors
 283 Workbench
 4 Cloud Amplifier
 4 Federated
 2.7K Transform
 90 SQL DataFlows
 569 Datasets
 2K Magic ETL
 3.4K Visualize
 2.4K Charting
 601 Beast Mode
 15 App Studio
 29 Variables
 600 Automate
 151 Apps
 418 APIs & Domo Developer
 29 Workflows
 2 DomoAI
 28 Predict
 12 Jupyter Workspaces
 16 R & Python Tiles
 362 Distribute
 99 Domo Everywhere
 261 Scheduled Reports
 2 Software Integrations
 98 Manage
 95 Governance & Security
 15 Product Releases
 Community Forums
 37 Getting Started
 28 Community Member Introductions
 90 Community Announcements
 4.8K Archive