Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
BARC’s The BI Survey 19 makes it official. BI users love Qlik. GET REPORT
cchadda91
New Contributor III

Creating calendar

Hello All,

I am trying to create a calendar , but it throws error basically it is not able to capture the date inside the variable vMinDate and vMaxDate. However if i do $(vMindate) and $(vmaxDate) it returns the date appropriately.

Capture.PNG

set vMinDate = date(min(date_va));

set vMaxDate = date(max(date_va));

test:

LOAD * INLINE [

    id, date_va

    1, 02/11/2015

    2, 03/23/2016

    3, 11/20/2016

    4, 09/22/2017

    5, 05/22/2012

];

tempcalendar:

load

  $(vMinDate)  +IterNo()-1 as strtDateNum,

     $(vMinDate) +IterNo()-1 as startdate

     AutoGenerate 1

     while $(vMinDate)  + IterNo()-1 <= $(vMaxDate);

12 Replies
Partner
Partner

Re: Creating calendar

Hi,

It seems to be working as expected, could you elaborate on what it is that you are looking for?

cchadda91
New Contributor III

Re: Creating calendar

Thanks karthik for prompt response.

But it dosent work it throws error, basically i was looking for a short work around creating master calendar. So if i refer (IMG 1 below i wanted in vMinDate if i can get the values calculate from within the script/ field .

my scipt

set vMinDate = date(min(date_va));

set vMaxDate = date(max(date_va));

but when i reload it shows error  as shown in question

IMG 1

Capture.PNG

Re: Creating calendar

May be date_va is the field is not working for you

Can you check in Text box -- =$(vMinDate)

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

Re: Creating calendar

These are the issues am seeing:

1. The 2 variables are referring to a field that is created after the variables are defined.

2. You cannot use date(min(date_va)) , this is how we'd use it in a chart, not in the script. In the script, you'd have to do a

temp_min_table:

load

min(date_va) as test_min_date,

max(date_va) as test_max_date

resident

test;

and then

set vMinDate = peek('test_min_date',-1,'temp_min_table');

set vMaxDate = peek('test_max_date',-1,'temp_min_table');

You can then use the vMinDate and vMaxDate in your next reload.

Hope this helps.

cchadda91
New Contributor III

Re: Creating calendar

Capture.PNG

yes anil.using text box it work, as mentioned earlier

cchadda91
New Contributor III

Re: Creating calendar

yea i checked on this as an alternative i know this approach.

like we have to create a field and then load min max date in variable using peek function..

so i was being curious why can t we procees just by storing min/max in variable itself i was not confident with the reason as to why we cant do straight away..

Partner
Partner

Re: Creating calendar

It's just the way the Qlik syntax work. All aggregations in the script level happen via a load statement, in the chart level, they are similar to 'functions' that we can use.

Re: Creating calendar

Hi,

try below

set vMinDate = '=date(min(date_va))';

set vMaxDate = '=date(max(date_va))';

Regards

Great dreamer's dreams never fulfilled, they are always transcended.
Highlighted
cchadda91
New Contributor III

Re: Creating calendar

set vMinDate = '=date(min(date_va))';

set vMaxDate = '=date(max(date_va))';

below error

Capture.PNG