Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Help with variable NULL value

Hi Community,

I have a problem with a variable whichI don't know why is set to NULL.

The situation is as follows.

1. I have a date field from table GA

2. I have a second date field from table PS

3. What I want to get is the most recent date of the two fields, then compare them and keep the biggest one, i.e. the most recent date in numeric format

4. What I've done is to load the two fields and use two different variables MaxDate_1 and MaxDate_2 to store the biggest (most recent) date of the two differente fields. After that I wanted to use a third variable to store the maximum of MaxDate_1 and MaxDate_2 and here is where the problem comes.

I've checked the variables and MaxDate_1 and MaxDate_2 store numeric values (it seems that part works) but MaxDate is ends up being NULL

5. Could you please check the end line and tell me if there is any syntax mistake?

Thanks in advance.

---

GA:

LOAD

    "Date"

FROM [xxx];

PS:

LOAD

    invoice_date

FROM [xxx];

Temp:

LOAD

    Max("Date") as MaxDate_1

    Resident GA;

    LET vMaxDate_1 = floor(peek('MaxDate_1'));

Drop Table Temp;

Temp:

LOAD

    Max("invoice_date") as MaxDate_2

    Resident PS;

    LET vMaxDate_2 = floor(peek('MaxDate_2'));

Drop Table Temp;

Drop Table GA;

Drop Table PS;

LET vMaxDate = if(MaxDate_1>MaxDate_2,MaxDate_1,MaxDate_2);

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

You assigned vMaxDate_1 and used MaxDate_1 in your expression. Same with vMaxDate_2

LET vMaxDate = if(vMaxDate_1>vMaxDate_2,vMaxDate_1,vMaxDate_2);


HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

5 Replies
marcus_sommer

Try: LET vMaxDate = if($(MaxDate_1)>$(MaxDate_2),$(MaxDate_1),$(MaxDate_2));

- Marcus

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

You assigned vMaxDate_1 and used MaxDate_1 in your expression. Same with vMaxDate_2

LET vMaxDate = if(vMaxDate_1>vMaxDate_2,vMaxDate_1,vMaxDate_2);


HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
jonathandienst
Partner - Champion III
Partner - Champion III

Or I would use RangeMax to simplify it a little:


     LET vMaxDate = RangeMax(vMaxDate_1, vMaxDate_2);



Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Thanks Marcus.

Didn't work.

Still NULL.

Not applicable
Author

That was it.

Many thanks and also for the additional recommendation.

M.