Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to calculate rolling sum within a calendar year #8975

Open
SabinaHisamova opened this issue Nov 20, 2024 · 0 comments
Open

How to calculate rolling sum within a calendar year #8975

SabinaHisamova opened this issue Nov 20, 2024 · 0 comments
Labels
question The issue is a question. Please use Stack Overflow for questions.

Comments

@SabinaHisamova
Copy link

At the moment, rollingWindow leading and trailing parameters supports values in the following format: (-?\d+) (minute|hour|day|week|month|year) which can be used to define the window size to the right and left of the offset.

I need to calculate the accumulated sum of parameter (income_per_mth) within a year, i.e. start calculating the accumulated parameter again with the onset of January of the following year. The granularity of the data is the month.

I tried to formulate this logic as follows:

accum_param : {
    title: 'accum_param_year',		
      sql: `income_per_mth`,		
      type: `sum`,  
      rolling_window: {
        offset: 'end',
        trailing: '1 year'
      },
}

But it doest start over the calculation in January of the next year. It works with a granularity of a month, i.e.
it counts the accumulated parameter within 12 months, and not within a certain year. For example, for March 2024, the calculation will start from March 2023, but I need it to start from January 2024.

Please suggest how I can solve my problem.

@SabinaHisamova SabinaHisamova added the question The issue is a question. Please use Stack Overflow for questions. label Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question The issue is a question. Please use Stack Overflow for questions.
Projects
None yet
Development

No branches or pull requests

1 participant