Activation Time <10
I'm trying to get a percentage of less than 10 mints, in dataset I have values where start time is before the arrival time and instead of counting them as negative it displaying positive, how Can I fix this.
SUM((CASE
WHEN (TIME_TO_SEC(timeDIFF(`Start Time (UTC)`, `Arrival Time (UTC)`)) / 60) <=10 THEN 1
END))
/
SUM((CASE WHEN `Case Number` is not null then 1
end))
Best Answers

Ah the reason I'm not a fan of TIMEDIFF. In cases like this I prefer to use UNIX_TIMESTAMP and math to calculate the difference in seconds between two different timestamps.
SUM((CASE WHEN ((UNIX_TIMESTAMP(`Start Time (UTC)`)  UNIX_TIMESTAMP(`Arrival Time (UTC)`)) / 60) <=10 THEN 1 END)) / SUM((CASE WHEN `Case Number` is not null then 1 end))
One question of clarification  If a start time comes 15 minutes before the arrival time (15 minutes) should that be included since 15 < 10 or should it be excluded since the absolute duration is greater than 10? If it should be excluded you can wrap the subtraction in the ABS function to get the absolute value.
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**2 
You can use the ABS() function to turn any negative number into a positive number.
ABS
Returns the absolute value for all values in a numeric column.In other words, any negative values become positive, and positive values stay the same. This is valuable when you want to see aggregation without considering positive and negative values.
ABS('Operating Budget')
**Check out my Domo Tips & Tricks Videos
**Make sure to any users posts that helped you.
**Please mark as accepted the ones who solved your issue.1
Answers

You can utilize an additional clause inside your case statement to swap the values if necessary:
SUM((CASE WHEN `Start Time (UTC)` <= `Arrival Time (UTC)` AND (TIME_TO_SEC(timeDIFF(`Start Time (UTC)`, `Arrival Time (UTC)`)) / 60) <=10 THEN 1 WHEN `Start Time (UTC)` > `Arrival Time (UTC)` AND (TIME_TO_SEC(timeDIFF(`Arrival Time (UTC)`, `Start Time (UTC)`)) / 60) <=10 THEN 1 END)) / SUM((CASE WHEN `Case Number` is not null then 1 end))
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**0 
Thanks, but this is giving me no results also I need to include those rows.
0 
Try adding ELSE 0 in your case statement like this:
SUM((CASE WHEN (TIME_TO_SEC(timeDIFF(`Start Time (UTC)`, `Arrival Time (UTC)`)) / 60) <=10 THEN 1 ELSE 0 END)) / SUM((CASE WHEN `Case Number` is not null then 1 ELSE 0 end))
**Check out my Domo Tips & Tricks Videos
**Make sure to any users posts that helped you.
**Please mark as accepted the ones who solved your issue.0 
It will still not solve the problem as the Response time should be negative and not positive. like the first one 8 mints
0 
Interestingly, when I put this into my beast mode:
TIMEDIFF('4:46:11 PM','4:54:28 PM')
It resulted in a value of 23:51:43 rather than the negative approx. 8 minutes as you would expect. It seems as though Domo's implementation doesn't match MySQL's implementation, which is what it typically follows.
I think if you took this knowledge and added your time to sec function and then subtracted from 86400 (seconds in a day) and divide by 60, you will get to your minutes and be able to put this into your case statement.
I would suggest building this up gradually after adding each function and view the results in the table card to make sure you are seeing the results you would expect rather than trying to jump to the final result.
Hope this helps.
**Check out my Domo Tips & Tricks Videos
**Make sure to any users posts that helped you.
**Please mark as accepted the ones who solved your issue.0 
Ah the reason I'm not a fan of TIMEDIFF. In cases like this I prefer to use UNIX_TIMESTAMP and math to calculate the difference in seconds between two different timestamps.
SUM((CASE WHEN ((UNIX_TIMESTAMP(`Start Time (UTC)`)  UNIX_TIMESTAMP(`Arrival Time (UTC)`)) / 60) <=10 THEN 1 END)) / SUM((CASE WHEN `Case Number` is not null then 1 end))
One question of clarification  If a start time comes 15 minutes before the arrival time (15 minutes) should that be included since 15 < 10 or should it be excluded since the absolute duration is greater than 10? If it should be excluded you can wrap the subtraction in the ABS function to get the absolute value.
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**2 
Thank you Grant, this has solved the problem but not sure why it's counting the time more than 10 mints :(
it's only few rows and doesn't effect the # that much but still...
0 
is there a way to make the negative numbers into positive?
As this solve the problem with time but then when you sum it's not the right number.
0 
You can use the ABS() function to turn any negative number into a positive number.
ABS
Returns the absolute value for all values in a numeric column.In other words, any negative values become positive, and positive values stay the same. This is valuable when you want to see aggregation without considering positive and negative values.
ABS('Operating Budget')
**Check out my Domo Tips & Tricks Videos
**Make sure to any users posts that helped you.
**Please mark as accepted the ones who solved your issue.1 
thank you, Grant & Mark.
This really solve the problem :)
0
Categories
 All Categories
 1.2K Product Ideas
 1.2K Ideas Exchange
 1.3K Connect
 1K Connectors
 267 Workbench
 Cloud Amplifier
 3 Federated
 2.5K Transform
 78 SQL DataFlows
 524 Datasets
 1.9K Magic ETL
 2.9K Visualize
 2.2K Charting
 433 Beast Mode
 22 Variables
 508 Automate
 114 Apps
 386 APIs & Domo Developer
 8 Workflows
 26 Predict
 10 Jupyter Workspaces
 16 R & Python Tiles
 331 Distribute
 76 Domo Everywhere
 255 Scheduled Reports
 65 Manage
 65 Governance & Security
 1 Product Release Questions
 Community Forums
 40 Getting Started
 26 Community Member Introductions
 67 Community Announcements
 4.8K Archive