Period over period (MOM) insight should not take the entire previous month

Hey All,
I am using period over period computation insight with time granularity as month.

I want the comparison to be made such that current month to date value is compared with the previous month start to previous month current date but by default, the insight compares the month to date value to the entire previous month.

Is it possible to achieve this using insights ?

Hi,

Not sure if you need to select DAY as granularity but anyway, I ended up creating my own calculated fields, it is a tedious job but it works; note that each calculation will require you to create three functions (current period, previous period, and comparison).
Example of period-to-month, assuming that SelectedDate is a parameter you created, your_metric is a metric you want to sum and Created_On is the date dimension:

Current_Month

sumIf({your_metric}, {Created_On} <= ${SelectedDate} AND {Created_On} >= truncDate('MM', ${SelectedDate}))

Previous_Month:

sumIf({your_metric}, {Created_On} <= addDateTime(-1, 'MM', ${SelectedDate}) AND {Created_On} >= truncDate('MM', addDateTime(-1, 'MM', ${SelectedDate})))

And then you just do (Current_Month - Previous_Month) / Previous_Month.

NB: Maybe you will need to remove the equals and leave only greater than / smaller than, in your function, depending on your parameter.

1 Like

Hi @Massi ,
Thanks for your help.
This will work for pivots and direct percent change charts.
I am not sure if this will help me when creating insights.

If would look at subtracting dates.

So if you are on October 10 then subtract 10 days from your field.

It would look like this.

addDateTime(-dateDiff(now(),truncDate(‘MM’,now())),‘DD’,{date_field})

You would put that into your date field in your insight