Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
srikantj
Creator
Creator

calendar date

Hi qlikss,

Need some expalanation

i have calendar script:

LOAD

       min(datefield) as DateMin

       ,max(datefield) as DateMax

;

LOAD

       FieldValue('date', RecNo()) as datefield

AutoGenerate FieldValueCount('date');

to find max and     min values of date, we can directly use max,min functions.why we need last 2 lines in calendar script.

I mean  these 2 lines

LOAD

       FieldValue('date', RecNo()) as datefield

AutoGenerate FieldValueCount('date');

1 Solution

Accepted Solutions
avkeep01
Partner - Specialist
Partner - Specialist

You could skip the 2 lines if you direct pull data from the table with the field 'date'.

LOAD
date(DateMin + IterNo()) as [date]        
WHILE DateMin + IterNo() <= DateMax     
;

LOAD
min(datefield)-1 as DateMin
,
max(datefield) as DateMax
RESIDENT [Your table name];

View solution in original post

18 Replies
prma7799
Master III
Master III

with the help of this (FieldValue('date', RecNo()) ) you will get min or max date

You are creating dates your own using below script

LOAD

       FieldValue('date', RecNo()) as datefield

AutoGenerate FieldValueCount('date');

avkeep01
Partner - Specialist
Partner - Specialist

Hi Srikanth Jetti,

This part creates a dataset containing a date for every possible 'date'.

LOAD

       FieldValue('date', RecNo()) as datefield

AutoGenerate FieldValueCount('date');

Without this you should make a resident to the table where date exists. Because without any data you can't make a min or max value. But you're right when you just pull the min and max data from the table where the date field exists.

srikantj
Creator
Creator
Author

Can't I get min,max dates without these 2 lines.

Min(date) is enough to find minimum date

Same goes for maximum

prma7799
Master III
Master III

You can get min or max like this also

LET vDataMax= fLOOR(Today());

LET vDataMin=Floor(date(MakeDate(2011,04,01)));

srikantj
Creator
Creator
Author

Still I didn't get you.

We already have date values in date field. What do you mean by creating dataset again.

I just reloaded these 2 lines by commenting top 2 lines.

LOAD

       FieldValue('date', RecNo()) as datefield

AutoGenerate FieldValueCount('date');

After reload I got all ? Marks in datefield

Is these ? Marks are dataset

srikantj
Creator
Creator
Author

Yes I know this. I am supporting one qlikview application develop by someone.

I just want to know why he scripted like this

prma7799
Master III
Master III

Temp:

LOAD

       FieldValue('date', RecNo()) as datefield

AutoGenerate FieldValueCount('date');

LOAD

       min(datefield) as DateMin

       ,max(datefield) as DateMax

resident Temp;

avkeep01
Partner - Specialist
Partner - Specialist

What is the name of the table where the data field exists?

You've got 2 options for getting min and max dates.

1. Directly from your table:

LOAD

MIN(Date) AS MinDate,

MAX(Date) AS MaxDate

RESIDENT [Your table name];

2. Indirect by creating a table with all dates that exists in the field Date from your table with the date: [Your table name].

LOAD

MIN(Date) AS MinDate,

MAX(Date) AS MaxDate;LOAD

       FieldValue('date', RecNo()) as datefield

AutoGenerate FieldValueCount('date');

srikantj
Creator
Creator
Author

LOAD
date(DateMin + IterNo()) as [date]        
WHILE DateMin + IterNo() <= DateMax     
;

LOAD
min(datefield)-1 as DateMin
,
max(datefield) as DateMax
;

LOAD
FieldValue('date', RecNo()) as datefield
AutoGenerate FieldValueCount('date');

This is the script he used to generate calendar dates

What my question is why can’t we use just these lines to generaye calendar dates

LOAD
date(DateMin + IterNo()) as [date]         // Link Field
WHILE DateMin + IterNo() <= DateMax     
;

LOAD
min(datefield)-1 as DateMin
,
max(datefield) as DateMax
;

Why we need to use these 2 lines. I don’t think we need these 2 lines

LOAD
FieldValue('date', RecNo()) as datefield
AutoGenerate FieldValueCount('date');