Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
abhaysingh
Specialist II
Specialist II

Logic Help

HI Guys ,

Need one simple help,

I have one table in which continuous dates are available ,

i want to pick max of date at backend it self

Table:

Load Date

from Path;

let vMaxDate = max(Date);

it is not giving output to me ...

and

i want to use this variable in other table;

load

(vMaxDate - DueDate)   as Days

from Table;

How i can achieve this?

4 Replies
swuehl
MVP
MVP

You can do it like

SET DateFormat = 'MM/DD/YYYY'; // Adapt to your Date date format

TMP:

Load Max(Date) as MaxDate

from Path;

Let vMaxDate = Peek('MaxDate',0,'TMP');

pavan045
Contributor III
Contributor III

Hi Abhay,

You need to use peek() function while assigning the max(Date) to your variable.

Try this,

Table1:

Load max(Date) as MaxDate resident <Your table name>;

LET vMaxDate = Peek('MaxDate', '0', 'Table1');


Hope this will help.

Thank you.

sunny_talwar

Here is a sample sample to show how Stefan's idea will work:

Dates:

LOAD Date(MakeDate(2014, 12, 31) + RecNo()) as Date

AutoGenerate 300;

MaxDate:

LOAD Max(Date) as MaxDate

Resident Dates;

LET vMaxDate = Peek('MaxDate');

DROP Table MaxDate;

FactTable:

LOAD *,

  $(vMaxDate) - DueDate as Days;

LOAD * Inline [

Dim, DueDate

A, 06/03/2015

B, 03/13/2015

C, 02/25/2015

];


Capture.PNG

swuehl
MVP
MVP

And to explain it some more:

You can use aggregation functions like Max() only in a table LOAD.

Aggregation functions ‒ QlikView

You can then access the aggregated values, like the MaxDate in a variable assignment by the use of inter record functions like Peek()

Peek ‒ QlikView

If you then want to use the variable in another LOAD statement, you need to use dollar sign expansion of your variable:

Dollar-sign expansion using a variable ‒ QlikView