Sum of units sold, rolling 30 days

Looking to replicate the exact data layout above (side by side columns) in a table in Domo. So units sold by SKU by month (got this far) but also a column for rolling L30 Days sum. I created a new column in the dataset for count of days from current for each row DATEDIFF(CURDATE(),(Calendar Date
)) but having a challenge creating a parallel column SUM of units sold for rolling 30 days. Is there a beast mode for this or perhaps a better practice in ETL?
Thanks!!
Best Answer
-
sum(case when DATEDIFF(CURDATE(),`Calendar Date`) < = 30 then `Qty` else 0 end)
2
Answers
-
sum(case when DATEDIFF(CURDATE(),`Calendar Date`) < = 30 then `Qty` else 0 end)
2 -
Thanks Superman! Giving this a try, just so I understand would it be sum of the qty for L30 days from current date and if not within that date parameter than it is a 0 sum?
0 -
@Jacinta correct. When the date diff is less than 30 it will use qty value and if greater than 30 it will use 0. It will then sum all the values.
1
Categories
- All Categories
- 2K Product Ideas
- 2K Ideas Exchange
- 1.6K Connect
- 1.3K Connectors
- 311 Workbench
- 7 Cloud Amplifier
- 9 Federated
- 3K Transform
- 114 SQL DataFlows
- 654 Datasets
- 2.2K Magic ETL
- 4.1K Visualize
- 2.5K Charting
- 807 Beast Mode
- 80 App Studio
- 45 Variables
- 763 Automate
- 189 Apps
- 480 APIs & Domo Developer
- 76 Workflows
- 18 DomoAI
- 40 Predict
- 17 Jupyter Workspaces
- 23 R & Python Tiles
- 408 Distribute
- 119 Domo Everywhere
- 279 Scheduled Reports
- 10 Software Integrations
- 142 Manage
- 138 Governance & Security
- 8 Domo Community Gallery
- 47 Product Releases
- 12 Domo University
- 5.4K Community Forums
- 41 Getting Started
- 31 Community Member Introductions
- 114 Community Announcements
- 4.8K Archive