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.1K Product Ideas
 1.1K Ideas Exchange
 1.2K Connect
 970 Connectors
 259 Workbench
 Cloud Amplifier
 1 Federated
 2.4K Transform
 76 SQL DataFlows
 502 Datasets
 1.8K Magic ETL
 2.7K Visualize
 2.2K Charting
 379 Beast Mode
 21 Variables
 487 Automate
 104 Apps
 379 APIs & Domo Developer
 6 Workflows
 22 Predict
 6 Jupyter Workspaces
 16 R & Python Tiles
 319 Distribute
 67 Domo Everywhere
 252 Scheduled Reports
 59 Manage
 59 Governance & Security
 1 Product Release Questions
 5K Community Forums
 37 Getting Started
 23 Community Member Introductions
 64 Community Announcements
 4.8K Archive