beast mode within a beast mode
Hello,
I'm creating a card based upon the changes in tenure buckets of our sales reps. I am using start date and "As of" date (or the date we import the roster data. "As of" would be today's date, for instance).
From there, I want to bucket it into different ranges like "0-6 months," 1-2 years," and so on.
Another piece of this is there are many reps who have terminated. So in cases when there is a termination date present, I want to subtract start date from that date rather than "as of" date.
tl;dr : i need to beast mode the actual date difference of start date & today OR term date & start date
then i need to group these into digestible buckets.
This is what I have but I can't figure out how to format it:
CASE
when `Termination Date` is not NULL and
(when DATEDIFF(`Termination Date`, `Adjusted Start Date`) <180 then '0-6 Months'
when DATEDIFF(`Termination Date`, `Adjusted Start Date`) >=180 and DATEDIFF(`As Of`, `Adjusted Start Date`) <=365 then '6-12 Months'
when DATEDIFF(`Termination Date`, `Adjusted Start Date`) >365 and DATEDIFF(`As Of`, `Adjusted Start Date`) <=730 then '1-2 Years'
when DATEDIFF(`Termination Date`, `Adjusted Start Date`) > 730 then '2+ Years') else
when `Termination Date`is NULL and
(when DATEDIFF(`As Of`, `Adjusted Start Date`) <180 then '0-6 Months'
when DATEDIFF(`As Of`, `Adjusted Start Date`) >=180 and DATEDIFF(`As Of`, `Adjusted Start Date`) <=365 then '6-12 Months'
when DATEDIFF(`As Of`, `Adjusted Start Date`) >365 and DATEDIFF(`As Of`, `Adjusted Start Date`) <=730 then '1-2 Years'
when DATEDIFF(`As Of`, `Adjusted Start Date`) > 730 then '2+ Years')
END
Best Answer
-
Try this:
CASE
WHEN DATEDIFF(IFNULL(`Termination Date`,`As Of`),`Adjusted Start Date`)<180 THEN '0-6 Months'
WHEN DATEDIFF(IFNULL(`Termination Date`,`As Of`),`Adjusted Start Date`)<=365 THEN '6-12 Months'
WHEN DATEDIFF(IFNULL(`Termination Date`,`As Of`),`Adjusted Start Date`)<=730 THEN '1-2 Years'
WHEN DATEDIFF(IFNULL(`Termination Date`,`As Of`),`Adjusted Start Date`)>730 THEN '2+ Years'
ELSE 'Unknown'
ENDYou shouldn't really need the "ELSE 'Unknown'" line. I like to add it in just in case there are cases that are not included in the other buckets
0
Answers
-
Try this:
CASE
WHEN DATEDIFF(IFNULL(`Termination Date`,`As Of`),`Adjusted Start Date`)<180 THEN '0-6 Months'
WHEN DATEDIFF(IFNULL(`Termination Date`,`As Of`),`Adjusted Start Date`)<=365 THEN '6-12 Months'
WHEN DATEDIFF(IFNULL(`Termination Date`,`As Of`),`Adjusted Start Date`)<=730 THEN '1-2 Years'
WHEN DATEDIFF(IFNULL(`Termination Date`,`As Of`),`Adjusted Start Date`)>730 THEN '2+ Years'
ELSE 'Unknown'
ENDYou shouldn't really need the "ELSE 'Unknown'" line. I like to add it in just in case there are cases that are not included in the other buckets
0
Categories
- All Categories
- 1.9K Product Ideas
- 1.9K Ideas Exchange
- 1.6K Connect
- 1.3K Connectors
- 303 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 104 SQL DataFlows
- 637 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 763 Beast Mode
- 65 App Studio
- 42 Variables
- 709 Automate
- 184 Apps
- 460 APIs & Domo Developer
- 54 Workflows
- 11 DomoAI
- 39 Predict
- 16 Jupyter Workspaces
- 23 R & Python Tiles
- 401 Distribute
- 116 Domo Everywhere
- 277 Scheduled Reports
- 8 Software Integrations
- 134 Manage
- 131 Governance & Security
- 8 Domo Community Gallery
- 44 Product Releases
- 12 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 111 Community Announcements
- 4.8K Archive