Lag Window Functions gave me split rows
I am trying to use window functions for lag/lead. However no matter how I try, the table still show splits.
lag(sum(case when `control or target` = 'target' then `vol_usd` else 0 end)) over (partition by year(`trade_date`)*100 + month(`trade_date`))
Is there anything wrong here?
Answers
-
Sorry I used order by instead of partition. But in either case, both wont sum up but gave me 31 rows of 202101.
lag(sum(case when `control or target` = 'target' then `vol_usd` else 0 end)) over (order by year(`trade_date`)*100 + month(`trade_date`))
0 -
@jaeW_at_Onyx and @GrantSmith are the kings of window functions, so I am sure they can help you out. I would point you to these two resources:
- You can perform window functions in Magic ETL and they run very fast. Here is the KB article: https://knowledge.domo.com/Prepare/Magic_Transforms/ETL_DataFlows/03ETL_Actions%3A_Rank_and_Window
- Jae has a great youtube video about window functions here: https://www.youtube.com/watch?v=eifSYZIcPzg&t=361s
Hope this helps
**Check out my Domo Tips & Tricks Videos
**Make sure to any users posts that helped you.
**Please mark as accepted the ones who solved your issue.0 -
lag(sum(case when `control or target` = 'target' then `vol_usd` else 0 end)) over (partition by year(`trade_date`)*100 + month(`trade_date`))
I think Domo broke / changed functionality.
You can no longer use an expression in the partition or order by clause -- year(`trade_date`)*100 + month(`trade_date`)
add this to your dataset as a hardcoded column
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"3 -
Thanks @jaeW_at_Onyx & @MarkSnodgrass , adding an additional column works. Hopefully DOMO can fix this problem.
1
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.5K Connect
- 1.2K Connectors
- 299 Workbench
- 6 Cloud Amplifier
- 8 Federated
- 2.9K Transform
- 100 SQL DataFlows
- 616 Datasets
- 2.2K Magic ETL
- 3.8K Visualize
- 2.5K Charting
- 730 Beast Mode
- 55 App Studio
- 40 Variables
- 682 Automate
- 175 Apps
- 451 APIs & Domo Developer
- 46 Workflows
- 10 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
- 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