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.8K Product Ideas
- 1.8K Ideas Exchange
- 1.6K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 102 SQL DataFlows
- 626 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 753 Beast Mode
- 61 App Studio
- 41 Variables
- 692 Automate
- 177 Apps
- 456 APIs & Domo Developer
- 49 Workflows
- 10 DomoAI
- 38 Predict
- 16 Jupyter Workspaces
- 22 R & Python Tiles
- 398 Distribute
- 115 Domo Everywhere
- 276 Scheduled Reports
- 7 Software Integrations
- 130 Manage
- 127 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 11 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 110 Community Announcements
- 4.8K Archive