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.8K Product Ideas
- 1.8K Ideas Exchange
- 1.5K Connect
- 1.2K Connectors
- 297 Workbench
- 6 Cloud Amplifier
- 8 Federated
- 2.9K Transform
- 100 SQL DataFlows
- 614 Datasets
- 2.2K Magic ETL
- 3.8K Visualize
- 2.5K Charting
- 729 Beast Mode
- 53 App Studio
- 40 Variables
- 677 Automate
- 173 Apps
- 451 APIs & Domo Developer
- 45 Workflows
- 8 DomoAI
- 34 Predict
- 14 Jupyter Workspaces
- 20 R & Python Tiles
- 394 Distribute
- 113 Domo Everywhere
- 275 Scheduled Reports
- 6 Software Integrations
- 121 Manage
- 118 Governance & Security
- Domo Community Gallery
- 32 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 108 Community Announcements
- 4.8K Archive