How to get Prior Year Values on the same table row
I’m trying to create a row which shows the “Prior Year” value against a field for comparison, simply a 12 month offset of the data as shown below with the "Value" field. This would later enable me to create YoY differences.
I will also note that I'm looking for a solution that should be able to transcend filters i.e. you see in the table above I’ve filtered so the Payment Month doesn’t go before October 2023, but that the Prior Yr value is still picking up the results from before then for comparison (i.e. 44,256 value is actually from Oct 2022)
I’ve tried looking at various online resources and materials from Domo, but haven't yet found a reference to how this can be done. Some other questions and solutions always refer to a CURRENT_DATE() in the formula, but as you can see above this table is entirely agnostic of a date relative to now. There’s also the “period over period” charts, but none of those help me achieve it for a table as above.
The values in this table are aggregated up to months from granular data.
Note: The above screenshot shows this working in the ThoughtSpot environment, and I'm trying to achieve the same thing in Domo. For reference, here’s the TS formula that achieves this:
group_aggregate (moving_sum(Value ,12,-12, Monthly Payment Date) , query_groups ( ) , {} )
To explain it: it’s a window function moving sum. The 12 and -12 refer to “how far backwards” and “how far forwards” do we want to sum respectively. By setting it to 12 backwards and -12 forwards, it actually sets the range to a single month one year ago. It’s a bit of a workaround, but has worked there very well. I haven't seen such moving window functions for Domo beast mode.
Best Answers
-
You can use a beastmode:
LAG(SUM(
Value
),12) OVER(ORDER BYMonthly Payment Date
)If I solved your problem, please select "yes" above
0 -
Alternatively you can restructure your data so that for each date you have the values for the current date and last year to allow for easier filtering. I've done a write up on how to do this here:
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**0
Answers
-
You can use a beastmode:
LAG(SUM(
Value
),12) OVER(ORDER BYMonthly Payment Date
)If I solved your problem, please select "yes" above
0 -
Alternatively you can restructure your data so that for each date you have the values for the current date and last year to allow for easier filtering. I've done a write up on how to do this here:
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**0
Categories
- All Categories
- 1.9K Product Ideas
- 1.9K Ideas Exchange
- 1.6K Connect
- 1.3K Connectors
- 303 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 104 SQL DataFlows
- 638 Datasets
- 2.2K Magic ETL
- 4K Visualize
- 2.5K Charting
- 766 Beast Mode
- 69 App Studio
- 43 Variables
- 714 Automate
- 185 Apps
- 460 APIs & Domo Developer
- 55 Workflows
- 14 DomoAI
- 39 Predict
- 16 Jupyter Workspaces
- 23 R & Python Tiles
- 402 Distribute
- 116 Domo Everywhere
- 277 Scheduled Reports
- 9 Software Integrations
- 134 Manage
- 131 Governance & Security
- 8 Domo Community Gallery
- 44 Product Releases
- 12 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 111 Community Announcements
- 4.8K Archive