How to wrap a DATEDIFF around this?
As always, I probably shouldn't be allowed near Beast Mode :)
Can someone explain how to fix my code? I assume I'm not adding DATEDIFF in the right place, as I'm always breaking it. BatchTimestamp is the date the Phase was set to the respective value. I just need the number of days between the two.
CASE WHEN `Phase` = 'Received' THEN `BatchTimestamp` END - CASE WHEN `Phase` = 'Ready' THEN `BatchTimestamp` END
Thanks!
Answers
-
When you're evaluating this beast mode it's going record by record so one part of your equation will always be null, you'd need to calculate the max BatchTimestamp date. Are you keying based off a specific identifier field in your chart?
Something along the lines of may work depending on how you're displaying your data:
DATEDIFF(MAX(CASE WHEN `Phase` = 'Ready' THEN `BatchTimestamp` END), MAX(CASE WHEN `Phase` = 'Received' THEN `BatchTimestamp` END))
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**0 -
Hi @GrantSmith , thank you for your help as always. I am not following why I need to include MAX, but perhaps I left out a key piece of information in my previous post. I need the total number of days between these phase change dates for all records, and I would then set the Aggregation to be the Average. It's the Average between them that I'm ultimately looking for.
0 -
Do you have some sample data to see what your dataset looks like?
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**0 -
Hi Grant, is this helpful? Just note the header labels are a little different from my code earlier which was more of a mockup, but the two Phases I'm interested in here are the ones starting A0 and A3, and I need to know the average number of days between the dates they were set for all records that have had both set (or the total days, then I can set Aggregation to Average). Thank you so much.
0 -
How do you know which record the
A0 - Request Received
and theA3 - Ready for IT PB
belongs to, in your example you have 2A0 - Request Received
entries, also can a record have more than one of each of these entries, and if so, which one should be used (this is why @GrantSmith suggesting wrapping the field in a MAX function), an aggregation function will always be needed since the dates are not held on separate columns of the same row, but different rows instead.0 -
The table from my screenshot includes the record name also, but I can't show that here. A record appears as many times as there are Phase changes.
It's incredibly rare (<1% of the time) that a project would have more than one transition from A0 to A3, but if it does, I would like them all included in the calculation.
0
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.5K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 8 Federated
- 2.9K Transform
- 100 SQL DataFlows
- 616 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 738 Beast Mode
- 57 App Studio
- 40 Variables
- 685 Automate
- 176 Apps
- 452 APIs & Domo Developer
- 47 Workflows
- 10 DomoAI
- 36 Predict
- 15 Jupyter Workspaces
- 21 R & Python Tiles
- 394 Distribute
- 113 Domo Everywhere
- 275 Scheduled Reports
- 6 Software Integrations
- 124 Manage
- 121 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 108 Community Announcements
- 4.8K Archive