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.4K Product Ideas
- 1.4K Ideas Exchange
- 1.4K Connect
- 1.2K Connectors
- 284 Workbench
- 4 Cloud Amplifier
- 4 Federated
- 2.9K Transform
- 89 SQL DataFlows
- 556 Datasets
- 2.2K Magic ETL
- 3.3K Visualize
- 2.3K Charting
- 569 Beast Mode
- 10 App Studio
- 27 Variables
- 578 Automate
- 140 Apps
- 414 APIs & Domo Developer
- 23 Workflows
- 1 DomoAI
- 28 Predict
- 12 Jupyter Workspaces
- 16 R & Python Tiles
- 350 Distribute
- 90 Domo Everywhere
- 258 Scheduled Reports
- 2 Software Integrations
- 92 Manage
- 89 Governance & Security
- 9 Product Release Questions
- Community Forums
- 42 Getting Started
- 28 Community Member Introductions
- 85 Community Announcements
- 4.8K Archive