periodOverPeriodLastValue skipping months

The AI recommended “periodOverPeriodLastValue” as a great way to get what I want in a calculated field. But it only works sometimes and skips some months? What’s up with that?

I need to use the prior month’s value in some calculations. Even creating a dummy dataset here, you can see that sometimes the correct prior month value is populated, but other months are not. It’s sorta an alternating pattern.

My dates are the last day of the month, perhaps that creates a problem somehow?

periodOverPeriod Error

Hi @Shannon ,

welcome to the community :tada:

The Lag function gives you the value from the previous line.

lag(sum({Value}), [{month_end_day} ASC], 1)

Best Regards,
Nico

PS: I tried to truncDate your date field, but when I do the periodOverPeriodLastValue function shows nothing.

1 Like

Thanks Nico,
The lag function is helping me some, but my real data has many slices, so I’m having trouble getting the lag function to work over all the groups required.

Lag feels a bit brute; “Give me the row above” vs “give me this value only a month ago” which is what I’m looking for.