Conditional DATEDIFF
I have a query that returns the number of business days between two dates for a ticketing system. I'm trying to determine average resolution times for our support tickets and have a beast mode that works for the total number of business days between case open and case resolved.
CASE DATEDIFF(`Resolved Date`, `Case Creation Date`)
WHEN 0 THEN
ROUND((HOUR(`Resolved Date`) + (MINUTE(`Resolved Date`)/60)) - (HOUR(`Case Creation Date`) + (MINUTE(`Case Creation Date`) / 60)))
ELSE
ROUND(
(17 - (HOUR(`Case Creation Date`) + (MINUTE(`Case Creation Date`)/60)))
+
(
5 * FLOOR(DATEDIFF(`Resolved Date`, `Case Creation Date`) / 7)
+
CASE SUBSTRING('0012345400123433001232230012112300100123000012340', 7 * (WEEKDAY(`Case Creation Date`) - 1) + WEEKDAY(`Resolved Date`), 1)
WHEN '0' THEN 0
WHEN '1' THEN 1
WHEN '2' THEN 2
WHEN '3' THEN 3
WHEN '4' THEN 4
WHEN '5' THEN 5
END
) * 8
+
((HOUR(`Resolved Date`) + (MINUTE(`Resolved Date`)/60)) - 9)
)
END/8
Now, rather than the total number of business days for all tickets, I'm wanting to filter in the beastmode by a case label to get average times when tickets are escalated to our T2 support or our T3 support.
IE
WHEN `Case Labels` LIKE '%T3%' THEN DATEDIFF...
Is it possible to nest this condition before I run all my DATEDIFF logic? Something like:
CASE
WHEN `Case Labels` LIKE '%T3%' THEN
DATEDIFF(`Resolved Date`, `Case Creation Date`)
WHEN 0 THEN
ROUND((HOUR(`Resolved Date`) + (MINUTE(`Resolved Date`)/60)) - (HOUR(`Case Creation Date`) + (MINUTE(`Case Creation Date`) / 60)))
ELSE
ROUND(
(17 - (HOUR(`Case Creation Date`) + (MINUTE(`Case Creation Date`)/60)))
+
(
5 * FLOOR(DATEDIFF(`Resolved Date`, `Case Creation Date`) / 7)
+
CASE SUBSTRING('0012345400123433001232230012112300100123000012340', 7 * (WEEKDAY(`Case Creation Date`) - 1) + WEEKDAY(`Resolved Date`), 1)
WHEN '0' THEN 0
WHEN '1' THEN 1
WHEN '2' THEN 2
WHEN '3' THEN 3
WHEN '4' THEN 4
WHEN '5' THEN 5
END
) * 8
+
((HOUR(`Resolved Date`) + (MINUTE(`Resolved Date`)/60)) - 9)
)
END/8
Can anyone help as to how I would format this?
Thanks.
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
- 754 Beast Mode
- 61 App Studio
- 41 Variables
- 693 Automate
- 178 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