Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
Modernize Your QlikView Deployment webinar, Nov. 3rd. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Contributor
Contributor

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
Highlighted
Partner
Partner

Try this in your search string:

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

View solution in original post

11 Replies
Highlighted
Partner
Partner

MONTH(TODAY())-2 didnt work?

Highlighted
Contributor
Contributor

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.

Highlighted

I would think this way

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

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

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
Highlighted
Partner
Partner

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

Highlighted
Contributor
Contributor

Hi again

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

Highlighted

May be there is no data for one month?

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
Highlighted
Partner
Partner

Try this in your search string:

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

View solution in original post

Highlighted
Partner
Partner

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

Thanks.

Highlighted
Contributor
Contributor

Hip, hip Hooray!.....

That's the one!  Thanks a 1.000.000