Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
PGesterkamp
Contributor III
Contributor III

Trigger a period for the two previous months

Hello

On entering a sheet I would like it to be automaticly set for the period of  the two previous months as from today.  I have used:

 

(in the textfield search I wrote:)

=MONTH(TODAY())-1  (that works, but only for one month). How can I expand my range with 2 months?

1 Solution

Accepted Solutions
Arthur_Fong
Partner - Specialist III
Partner - Specialist III

Try this in your search string:

='(' &text(month(AddMonths(today(),-2)))&'|'&text(month(AddMonths(today(),-1)))& ')'

View solution in original post

11 Replies
Arthur_Fong
Partner - Specialist III
Partner - Specialist III

MONTH(TODAY())-2 didnt work?

PGesterkamp
Contributor III
Contributor III
Author

Hi Partner

The string works, but the result is that it gives the month before the previous month .

Today the monthnumber = 8 , and  I would like to see monthnumber  6 AND 7 on entering the sheet.

Anil_Babu_Samineni

I would think this way

=AddMonths(MONTH(TODAY()), -2)

='>=' & AddMonths(MONTH(TODAY()), -2) & '<' & MONTH(TODAY())

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Arthur_Fong
Partner - Specialist III
Partner - Specialist III

A more robust expression will be :

=ADDMONTHS(TODAY(),-2)

 

Addmonths() able to capture cross year while month() cannot work in that manner.

For example if we currently at Jan 2019,

Addmonths(today(),-2) can back track till Nov 2018, while month(today())-2 will show null.

 

Thanks and regards,

Arthur Fong

PGesterkamp
Contributor III
Contributor III
Author

Hi again

thanks 4 all the effort but both solutions still give zero result.  Seems to working for only 1 month 

Anil_Babu_Samineni

May be there is no data for one month?

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Arthur_Fong
Partner - Specialist III
Partner - Specialist III

Try this in your search string:

='(' &text(month(AddMonths(today(),-2)))&'|'&text(month(AddMonths(today(),-1)))& ')'

Arthur_Fong
Partner - Specialist III
Partner - Specialist III

Remove text() if your month dimension is a date or num field.

Thanks.

PGesterkamp
Contributor III
Contributor III
Author

Hip, hip Hooray!.....

That's the one!  Thanks a 1.000.000