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
- 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