Skip to content

How to calculate rolling sum within a calendar yearΒ #8975

@SabinaHisamova

Description

@SabinaHisamova

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionThe issue is a question. Please use Stack Overflow for questions.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions