Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Addmonths with max date

Hi I'm trying to use the addmonths function, but apparently can't get the syntax right.  Any help is greatly appreciated!

=AddMonths({$<(=max(vDate))>}, -1, 1)

1 Solution

Accepted Solutions
MK_QSL
MVP

If vDate is variable

AddMonths('$(vDate)', 1)

This will add one month to your vDate

If vDate is normal date

AddMonths ('max(vDate )', 1)

Try both of the above formula with and without single quotes

I. E.  ''

In Set Analysis.... Something like below

Sum({$<Month = {'$(=AddMonths(max(vDate)), 1)'}>}Sales)

View solution in original post

4 Replies
MK_QSL
MVP

If vDate is variable

AddMonths('$(vDate)', 1)

This will add one month to your vDate

If vDate is normal date

AddMonths ('max(vDate )', 1)

Try both of the above formula with and without single quotes

I. E.  ''

In Set Analysis.... Something like below

Sum({$<Month = {'$(=AddMonths(max(vDate)), 1)'}>}Sales)

Not applicable
Author

Thank you!  That isolated addmonths function now works.  But to your last set analysis example, how would I correct the following expression I'm using in a chart (focusing on the avg function):

//find average of the field Sales for when the field Vintage is between the latest date and 2 years before

avg({$<Vintage={">=$(=AddMonths(max(Vintage),-24,1))<=$(=max(Vintage))"}>} [Sales])

Needless to say, I'm struggling with the nested functions.

MK_QSL
MVP

Can you share your sample file or apps?

Not applicable
Author

Unfortunately I can't (size and proprietary).  But the structure looks like this:

INLINE [

  Vintage, Sales, State

  10/31/2009, 124303, Texas

  10/31/2009, 84902, Florida

  11/30/2009, 372928, California

  11/30/2009, 84449, Ohio

  12/31/2009, 48272, Indiana

];

I have a chart with the State as a dimension, and the vintages run for about 5 years (with all values at end of month).  Trying to find the average sales over the past 24 months in a given state.  Thanks!