Rolling 12 Months Calculation

Trying to get the below into DOMO (below is done in PBI)
Monthly - 01/12/2024 - 31/12/2024 (1 Month) - Works for each month using the calculation - COUNT(DISTINCT Incident Number
)
Rolling - 01/01/2024 - 31/12/2024 (12 Months) - Need help
FYTD - 01/04/2024 - 31/12/2024 (Apr 2024 - Dec 2024) - Need help
Comments
-
You can use the following for SSI Rolling:
(
SUM(SSI Monthly
) +
LAG(SUM(SSI Monthly
), 11) OVER (ORDER BYYear-Month
) +
LAG(SUM(SSI Monthly
), 10) OVER (ORDER BYYear-Month
) +
LAG(SUM(SSI Monthly
), 9) OVER (ORDER BYYear-Month
) +
LAG(SUM(SSI Monthly
), 8) OVER (ORDER BYYear-Month
) +
LAG(SUM(SSI Monthly
), 7) OVER (ORDER BYYear-Month
) +
LAG(SUM(SSI Monthly
), 6) OVER (ORDER BYYear-Month
) +
LAG(SUM(SSI Monthly
), 5) OVER (ORDER BYYear-Month
) +
LAG(SUM(SSI Monthly
), 4) OVER (ORDER BYYear-Month
) +
LAG(SUM(SSI Monthly
), 3) OVER (ORDER BYYear-Month
) +
LAG(SUM(SSI Monthly
), 2) OVER (ORDER BYYear-Month
) +
LAG(SUM(SSI Monthly
), 1) OVER (ORDER BYYear-Month
))FYTD:
(
SUM(CASE WHENYear-Month
>= '2024-04-01' THENSSI Monthly
END) +
LAG(SUM(CASE WHENYear-Month
>= '2024-04-01' THENSSI Monthly
END), 11) OVER (ORDER BYYear-Month
) +
LAG(SUM(CASE WHENYear-Month
>= '2024-04-01' THENSSI Monthly
END), 10) OVER (ORDER BYYear-Month
) +
LAG(SUM(CASE WHENYear-Month
>= '2024-04-01' THENSSI Monthly
END), 9) OVER (ORDER BYYear-Month
) +
LAG(SUM(CASE WHENYear-Month
>= '2024-04-01' THENSSI Monthly
END), 8) OVER (ORDER BYYear-Month
) +
LAG(SUM(CASE WHENYear-Month
>= '2024-04-01' THENSSI Monthly
END), 7) OVER (ORDER BYYear-Month
) +
LAG(SUM(CASE WHENYear-Month
>= '2024-04-01' THENSSI Monthly
END), 6) OVER (ORDER BYYear-Month
) +
LAG(SUM(CASE WHENYear-Month
>= '2024-04-01' THENSSI Monthly
END), 5) OVER (ORDER BYYear-Month
) +
LAG(SUM(CASE WHENYear-Month
>= '2024-04-01' THENSSI Monthly
END), 4) OVER (ORDER BYYear-Month
) +
LAG(SUM(CASE WHENYear-Month
>= '2024-04-01' THENSSI Monthly
END), 3) OVER (ORDER BYYear-Month
) +
LAG(SUM(CASE WHENYear-Month
>= '2024-04-01' THENSSI Monthly
END), 2) OVER (ORDER BYYear-Month
) +
LAG(SUM(CASE WHENYear-Month
>= '2024-04-01' THENSSI Monthly
END), 1) OVER (ORDER BYYear-Month
))Results (I don't have the rest of your data to go farther back, but the numbers are matching with what I do have:
If I solved your problem, please select "yes" above
0 -
@ColemenWilson can this be done in beast mode or is your example done via magic ETL ?
Additionally, would this methodology work if you had a transaction table with day date granularity or does your methodology require you to create a summary table truncating the day > month ?
0 -
This is using a beastmode. I built it assuming month level granularity.
If I solved your problem, please select "yes" above
0 -
@ColemenWilson LAG() doesn't appear when I search functions in beast mode. Any thoughts ?
0 -
It will still work, it just doesn't show up in the functions list - along with many other mysql functions.
If I solved your problem, please select "yes" above
1 -
@ColemenWilson - the below beast mode calculation is not giving me an error but when I insert into the table, I get an error "An issue has occurred during processing. We are unable to complete the request at this time - 'undefined' "
(
SUM(SSI Monthly
) +
LAG(SUM(SSI Monthly
), 11) OVER (ORDER BYIncident Date (Year-Month)
) +
LAG(SUM(SSI Monthly
), 10) OVER (ORDER BYIncident Date (Year-Month)
) +
LAG(SUM(SSI Monthly
), 9) OVER (ORDER BYIncident Date (Year-Month)
) +
LAG(SUM(SSI Monthly
), 8) OVER (ORDER BYIncident Date (Year-Month)
) +
LAG(SUM(SSI Monthly
), 7) OVER (ORDER BYIncident Date (Year-Month)
) +
LAG(SUM(SSI Monthly
), 6) OVER (ORDER BYIncident Date (Year-Month)
) +
LAG(SUM(SSI Monthly
), 5) OVER (ORDER BYIncident Date (Year-Month)
) +
LAG(SUM(SSI Monthly
), 4) OVER (ORDER BYIncident Date (Year-Month)
) +
LAG(SUM(SSI Monthly
), 3) OVER (ORDER BYIncident Date (Year-Month)
) +
LAG(SUM(SSI Monthly
), 2) OVER (ORDER BYIncident Date (Year-Month)
) +
LAG(SUM(SSI Monthly
), 1) OVER (ORDER BYIncident Date (Year-Month)
)
)0 -
I think it is because you have both Incident Date and Year-Month in your ORDER BY. Also, do the fields in the beast mode match fields in your data? SSI Monthly, Incident Date, and Year-Month?
If I solved your problem, please select "yes" above
0 -
Beastmode calculation for Incident Date (Year-Month) is DATE_FORMAT(
Incident Date
,'%Y %m (%b)')Beastmode calculation for SSI Monthly is COUNT(DISTINCT
Incident Number
)0
Categories
- All Categories
- 2K Product Ideas
- 2K Ideas Exchange
- 1.6K Connect
- 1.3K Connectors
- 311 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 3.8K Transform
- 655 Datasets
- 115 SQL DataFlows
- 2.2K Magic ETL
- 811 Beast Mode
- 3.3K Visualize
- 2.5K Charting
- 80 App Studio
- 45 Variables
- 771 Automate
- 190 Apps
- 481 APIs & Domo Developer
- 77 Workflows
- 23 Code Engine
- 36 AI and Machine Learning
- 19 AI Chat
- AI Playground
- AI Projects and Models
- 17 Jupyter Workspaces
- 410 Distribute
- 120 Domo Everywhere
- 280 Scheduled Reports
- 10 Software Integrations
- 142 Manage
- 138 Governance & Security
- 8 Domo Community Gallery
- 48 Product Releases
- 12 Domo University
- 5.4K Community Forums
- 41 Getting Started
- 31 Community Member Introductions
- 114 Community Announcements
- 4.8K Archive