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.1K Product Ideas
- 1.1K Ideas Exchange
- 1.2K Connect
- 968 Connectors
- 256 Workbench
- Cloud Amplifier
- 1 Federated
- 2.4K Transform
- 76 SQL DataFlows
- 500 Datasets
- 1.8K Magic ETL
- 2.7K Visualize
- 2.2K Charting
- 368 Beast Mode
- 19 Variables
- 483 Automate
- 101 Apps
- 378 APIs & Domo Developer
- 6 Workflows
- 22 Predict
- 6 Jupyter Workspaces
- 16 R & Python Tiles
- 316 Distribute
- 64 Domo Everywhere
- 252 Scheduled Reports
- 59 Manage
- 59 Governance & Security
- 1 Product Release Questions
- 5K Community Forums
- 37 Getting Started
- 23 Community Member Introductions
- 63 Community Announcements
- 4.8K Archive