brandog
brandog

Reputation: 1527

Rolling Count of Values BETWEEN two dates, 12 to 24 months ago (SPOTFIRE Custom Expression)

I am struggling to create this calculation.

I need to create a rolling count of all of a columns values BETWEEN two dates. 12 to 24 months ago.

I do not want to do this by limiting data, I need it in the custom expression due to other work.

Currently I have this equation. I thought this would at least calculate all the values since two years ago but it fails to do that as well. Does anyone have a simpler way to calculate 12 to 24 months ago?

    (((Count(If(((Month([DATE])>=Month(DateAdd("mm",-24,DateTimeNow())))

 and (Year([DATE])>=Year(DateAdd("yy",-2,DateTimeNow())))),

[EXTRAPOLATEDPRESSURE],null)))))

Upvotes: 0

Views: 1493

Answers (1)

brandog
brandog

Reputation: 1527

Solved. I was making it to complex with the Month and Year aspects.

Count(If(([DATE]>=dateadd("mm",-24,DateTimeNow())) and ([DATE]<=dateadd("mm",-12,DateTimeNow())),

 [EXTRAPOLATEDPRESSURE],null))

Upvotes: 1

Related Questions