LAG / LEAD function misses the last iteration
Hi experts!
I'm using the lead / lag function in beast mode to find out the last row from each group of index rows simply by comparing the value of primary key of next/previous. It works accurately except it misses the last / first group (last when using lead and first when using lag).
Here's my beast mode code:
And, here's my data table and result of the calculated field...
If you see it correctly punches '1' for the group Canada, but misses for US. If I use the lag function, it punches value for US but misses for Canada.
One way I could think of is to punch '1' by default for the last row, but I couldn't found the way to use WHEN and identify the last row - if you could help me with that, it would be great.
---------------------------------------
Currently, I'm using a sloppy workaround of using both 😋 (see below) - it works but I want to do it much cleaner way.
Current workaround:
Best Answer
-
Hi - rank() and count() did the work!
0
Answers
-
Also, if there's only one group, then lead/lag doesn't work at all!!
So, in that case, I just want to punch '1' for the last row. Is there a way to use CASE..WHEN..END to punch a value for the last row? something like...
CASE
WHEN CURRENT_ROW() = LAST_ROW() THEN 1
END
==================================================================
Using MAX & FIXED BY works in general, see below...
... but when I apply filter on that calculated field to show only latest row, it picks the first row with blank version irrespectively. Ideally it should have filtered the row with version "2022-11-08-0014", however, it picks the row with blank version irrespectively. I even tried to sort the versions with descending order but doesn't work...
0 -
Hi - rank() and count() did the work!
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.8K Visualize
- 2.5K Charting
- 731 Beast Mode
- 55 App Studio
- 40 Variables
- 683 Automate
- 175 Apps
- 452 APIs & Domo Developer
- 46 Workflows
- 10 DomoAI
- 35 Predict
- 14 Jupyter Workspaces
- 21 R & Python Tiles
- 394 Distribute
- 113 Domo Everywhere
- 275 Scheduled Reports
- 6 Software Integrations
- 122 Manage
- 119 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 107 Community Announcements
- 4.8K Archive