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

Conditional Load

I am trying to do a conditional load based upon a date in the data. I am trying to use a preceding load statement, but get the error "field not found". I think there is a problem with the variable I set:

Load ...

     Date(OrderDate) as OrderDate

...;

let vRefDate = Year(Max(OrderDate));

Load ...

WHERE Year(OrderDate) < vRefDate;

1 Solution

Accepted Solutions
sunny_talwar

You cannot use Aggregation directly in your variable... try like this

Fact:

Load ...

    Date(OrderDate) as OrderDate

...;

Max:

LOAD Year(Max(OrderDate)) as MaxOrderDate

Resident Fact;

LET vRefDate = Peek('MaxOrderDate');

LOAD

WHERE Year(OrderDate) < vRefDate;

View solution in original post

4 Replies
sunny_talwar

You cannot use Aggregation directly in your variable... try like this

Fact:

Load ...

    Date(OrderDate) as OrderDate

...;

Max:

LOAD Year(Max(OrderDate)) as MaxOrderDate

Resident Fact;

LET vRefDate = Peek('MaxOrderDate');

LOAD

WHERE Year(OrderDate) < vRefDate;

joseph_bajo
Partner - Contributor
Partner - Contributor
Author

Thanks- this only returns 1 row though, and I want all data before this certain year. I think this is because there is only one row in the "Max" table.

sunny_talwar

What exactly do you have and what do you need to get?

joseph_bajo
Partner - Contributor
Partner - Contributor
Author

Thanks Sunny, I have figured it out.