Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

joseph_bajo
New 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
MVP
MVP

Re: Conditional Load

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;

4 Replies
MVP
MVP

Re: Conditional Load

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
New Contributor

Re: Conditional Load

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.

MVP
MVP

Re: Conditional Load

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

joseph_bajo
New Contributor

Re: Conditional Load

Thanks Sunny, I have figured it out.