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.5K Connect
- 1.2K Connectors
- 297 Workbench
- 6 Cloud Amplifier
- 8 Federated
- 2.9K Transform
- 100 SQL DataFlows
- 616 Datasets
- 2.2K Magic ETL
- 3.8K Visualize
- 2.5K Charting
- 729 Beast Mode
- 54 App Studio
- 40 Variables
- 678 Automate
- 173 Apps
- 451 APIs & Domo Developer
- 46 Workflows
- 8 DomoAI
- 34 Predict
- 14 Jupyter Workspaces
- 20 R & Python Tiles
- 394 Distribute
- 113 Domo Everywhere
- 275 Scheduled Reports
- 6 Software Integrations
- 121 Manage
- 118 Governance & Security
- Domo Community Gallery
- 32 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 108 Community Announcements
- 4.8K Archive