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
- 10.5K All Categories
- 8 Connect
- 918 Connectors
- 250 Workbench
- 470 Transform
- 1.7K Magic ETL
- 69 SQL DataFlows
- 477 Datasets
- 195 Visualize
- 253 Beast Mode
- 2.1K Charting
- 11 Variables
- 17 Automate
- 354 APIs & Domo Developer
- 89 Apps
- 3 Workflows
- 20 Predict
- 5 Jupyter Workspaces
- 15 R & Python Tiles
- 247 Distribute
- 63 Domo Everywhere
- 243 Scheduled Reports
- 21 Manage
- 42 Governance & Security
- 174 Product Ideas
- 1.2K Ideas Exchange
- 12 Community Forums
- 27 Getting Started
- 14 Community Member Introductions
- 55 Community News
- 4.5K Archive