Skip to main content
Solved

MOVINGSUM with a variable/metrics as WINDOW SIZE

  • August 19, 2023
  • 5 replies
  • 379 views

Forum|alt.badge.img+1
  • Master Trendsetter

Hi All, 

I am using MOVINGSUM which is very helpful but I stumbled on a challenge. 

I need to use a metrics as WINDOW SIZE rather than a fixed number. Basically the window size need to change dependently on month. I am getting the following error:

Error: Function MOVINGSUM requires second argument to be a scalar integer but is defined on Dimensions '00 Hub'::Month
Am I doing sth wrongly? Is there a workaround?

Regards,

Adam

Best answer by Fabien

Good morning,

This one was resolved yesterday during a session directly with Adam.
This is totally feasible by SELECTing the month in the driving metric of the window.

5 replies

Benoit
Community Manager
Forum|alt.badge.img+15
  • Community Manager
  • August 19, 2023

Hi,
could you maybe share your formula? And the type and structure of your window size metric?

Thanks


Fabien
Employee
Forum|alt.badge.img+1
  • Employee
  • Answer
  • August 24, 2023

Good morning,

This one was resolved yesterday during a session directly with Adam.
This is totally feasible by SELECTing the month in the driving metric of the window.


Forum|alt.badge.img+1
  • Author
  • Master Trendsetter
  • August 24, 2023

Yeap, all clear. Many thanks for your help!

Adam


Benji
Wallflower
Forum|alt.badge.img+7
  • Wallflower
  • August 24, 2023

Great to hear! :)


Benoit
Community Manager
Forum|alt.badge.img+15
  • Community Manager
  • September 4, 2023

Hi all,

Just a small note on this topic.

The resolution that Fabien offered was about finding an alternative formula without using Movingsum() because the window size argument can’t be dynamic.

Example:

Movingsum(Metric,3)

would be the same as doing

Metric + Metric[select:Month-1] + Metric[select: Month-2]