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"
  • kacy
    kacy Member

     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!

  • @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"