Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

danmercer
Contributor

Variable Date from Calendar

Hi All,

I have an app that has several calendars, and I am trying to create a variable based on a month date from that calendar date.  Everything that I can find so far seems to be a variable based on set dates, or other formulas such as Today(). 

What I'm looking for is essentially just the current OppMonthYear, less one month.

Calendar.JPG

Can this be done?

Tags (2)
7 Replies

Re: Variable Date from Calendar

Not entirely sure what you mean. But may be this:

Temp:

LOAD Date(AddMonths(Max(OppMonthYear), -1)) as NeededOppMonthYear

Resident Opp_Calendar;

SET vNeededOppMonthYear = Peek('NeededOppMonthYear');

DROP Table Temp;

danmercer
Contributor

Re: Variable Date from Calendar

Sunny,

You're on the right track regarding what I'm looking for.  However that script seems to return only a text value of Peek('NeededOppMonthYear');

Re: Variable Date from Calendar

What about this:

Temp:

LOAD Num(AddMonths(Max(OppMonthYear), -1)) as NeededOppMonthYear

Resident Opp_Calendar;

SET vNeededOppMonthYear = Peek('NeededOppMonthYear');

DROP Table Temp;

Not applicable

Re: Variable Date from Calendar

Hi Dan, try this:

Temp:

LOAD Num(AddMonths(Max(OppMonthYear), -1)) as NeededOppMonthYear

Resident Opp_Calendar;

SET vNeededOppMonthYear = Peek('NeededOppMonthYear' , 0 , Temp);

DROP Table Temp;


I hope that it help you! ifnot just ask us!


Agustin

danmercer
Contributor

Re: Variable Date from Calendar

Same thing.  It seems that the Peek is not coming back as a function.

danmercer
Contributor

Re: Variable Date from Calendar

Capture.JPG

Same thing as before. It seems that in both yours and Sunny's scrip it's not picking up the PEEK as a function.

Re: Variable Date from Calendar

I think i understand what you are trying to do. But the question is are you going to be using this variable in the script? because if you do, then you cannot use functions in scripts, you would need to change it to a static value. If this is for front end (and will change based on selections) then why don't you create this on the front end itself?