Way to Use Window Function to Find the Duration a Temperature Variable was Above a Threshold
I want to find a way to use a window function to find the duration a temperature variable was above a threshold, the timestamp at which the the temperature was above a threshold, and the range of temperatures when they were above the threshold.
The data is organized as an identifier column, the timestamp column, and the temperature column. Below is an example of the data that I am working with.
Identifier | Timestamp | Temperature |
---|---|---|
1 | 2022-07-08 10:00:00 | 47 |
1 | 2022-07-08 10:30:00 | 53 |
1 | 2022-07-08 11:00:00 | 57 |
1 | 2022-07-08 11:30:00 | 59 |
1 | 2022-07-08 12:00:00 | 44 |
2 | 2022-07-08 10:00:00 | 48 |
. . . |
Let's say that my threshold temperature is 50. I would thus want to find the time until the temperature goes back below 50, find the timestamp when the temperature was first above the threshold, find the range of these temperatures as the max and min, and find the Identifier that corresponds to the temperature going above the threshold. For example in the above table, I would want the following:
'Identifier: 1, Timestamp of first excursion: 2022-07-08 10:30:00, Temperature Range: 53-59, Excursion Duration: 1 hour 30 minutes'.
This dataset has over 400 million rows so I believe that the windowing function will be much more helpful than Magic ETL.
I am open to any suggestions and please feel free to send me any documentation that you think may be helpful.
Thanks! 😀
Answers
-
i may be missing something here, but I don’t think think I window function is needed.
create a variable for the temperature threshold.
Min temperature:
Min(case when ‘temperature’>=variable then ‘temperature’ end)
Do something similar for max.
min time:
Min(case when ‘temperature’>=variable then ‘time stamp’ end)
Then graph by identifier
1 -
Hi @ST_-Superman-_ ,
This is not exactly what I am looking for. I want to see how I can lead until a condition occurs so for the above example, I start in row 2 and I want to aggregate until a temperature drops below 50, which would be row 5. From this, I want to gather the first timestamp the temperature was above 50, the first timestamp the temperature drops below 50, the time difference between each of these timestamps, and the maximum and minimum temperatures during the time the temperatures were above 50.
I may have showed a too simplistic example as one identifier could have many temperature excursions above 50.
I thus think that a window function is useful for this problem because once I find out a way to use a lead function based on a condition, I am very confident I could do this.
0
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.6K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 102 SQL DataFlows
- 626 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 754 Beast Mode
- 61 App Studio
- 41 Variables
- 693 Automate
- 178 Apps
- 456 APIs & Domo Developer
- 49 Workflows
- 10 DomoAI
- 38 Predict
- 16 Jupyter Workspaces
- 22 R & Python Tiles
- 398 Distribute
- 115 Domo Everywhere
- 276 Scheduled Reports
- 7 Software Integrations
- 130 Manage
- 127 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 11 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 110 Community Announcements
- 4.8K Archive