Beast Mode windows function
Hey there I am trying to do a 5 day rolling change in value based on usage. I want to show previous five days compaired to the newest date.
I have tried this beast mode:
((Lag (`QUANTITY`,5) OVER (Order BY `TimeStamp(use)`)
+Lag(`QUANTITY`,6) OVER (Order BY `TimeStamp(use)`)
+Lag(`QUANTITY`,7) OVER (Order BY `TimeStamp(use)`)
+Lag(`QUANTITY`,8) OVER (Order BY `TimeStamp(use)`)
+Lag(`QUANTITY`,9) OVER (Order BY `TimeStamp(use)`))/5)
-
((`QUANTITY`
+Lag(`QUANTITY`,1) OVER (Order BY `TimeStamp(use)`)
+Lag(`QUANTITY`,2) OVER (Order BY `TimeStamp(use)`)
+Lag(`QUANTITY`,3) OVER (Order BY `TimeStamp(use)`)
+Lag(`QUANTITY`,4) OVER (Order BY `TimeStamp(use)`))/5)
however its giving an error. Any other thoughts?
on a side note we do have the window functions enabled.
thanks!
Comments
-
https://www.youtube.com/watch?v=cnc6gMKZ9R8
I did something like this in a tutorial video.
I think you need LAG(sum(quantity) , n )
Jae Wilson
Check out my 🎥 Domo Training YouTube Channel 👨💻
**Say "Thanks" by clicking the ❤️ in the post that helped you.
**Please mark the post that solves your problem by clicking on "Accept as Solution"0 -
Thank you so much. I have not had a chance to look close at the video as my day got away from me.... I did quickly try adding in sum but still getting an error. Will look at the video closer tomorrow. Really appreciate it!
0 -
@kacy no worrieis.
Pare a test function down to just one LAG() function.
Make sure that you're including `TimeStamp(use)` in the GROUP BY clause of the SQL function your table generates. The LAG() function must have the same granularity as the number of rows in your final visualization. (so Timestamp, must be on an axis or the SORT BY clause).
Jae Wilson
Check out my 🎥 Domo Training YouTube Channel 👨💻
**Say "Thanks" by clicking the ❤️ in the post that helped you.
**Please mark the post that solves your problem by clicking on "Accept as Solution"0
Categories
- All Categories
- 1.5K Product Ideas
- 1.5K Ideas Exchange
- 1.4K Connect
- 1.1K Connectors
- 278 Workbench
- 4 Cloud Amplifier
- 4 Federated
- 2.7K Transform
- 89 SQL DataFlows
- 561 Datasets
- 2K Magic ETL
- 3.4K Visualize
- 2.3K Charting
- 580 Beast Mode
- 13 App Studio
- 28 Variables
- 584 Automate
- 142 Apps
- 415 APIs & Domo Developer
- 26 Workflows
- 1 DomoAI
- 28 Predict
- 12 Jupyter Workspaces
- 16 R & Python Tiles
- 357 Distribute
- 96 Domo Everywhere
- 259 Scheduled Reports
- 2 Software Integrations
- 92 Manage
- 89 Governance & Security
- 9 Product Release Questions
- Community Forums
- 37 Getting Started
- 28 Community Member Introductions
- 89 Community Announcements
- 4.8K Archive