Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
sfloberg
Partner - Contributor III
Partner - Contributor III

where Years = Year(Now()) fail

I have a table who looks like this:

LOAD * INLINE [

Days, Years
1, 2015

2, 2015

3, 2015

4, 2016

5, 2016

]

where Years = Year(Now());


The loading of the script fill fail because 2017 isn't in the inline. How can I make the script not fail even if the year isn't in the inline yet?

When I try: where Years = Max(Years);. the script fails too by giving me: Unknown error.

How can i re-write the code so the loading of the script will not fail even if the year isn't in the inline yet?

11 Replies
surendraj
Specialist
Specialist

Hi,

LOAD * INLINE [

Days, Years

1, 2015

2, 2015

3, 2015

4, 2016

5, 2016

]

where Years =Previous(Years);

sfloberg
Partner - Contributor III
Partner - Contributor III
Author

But this will only give me the 2016 values. I need it to be the 2017 values.

sfloberg
Partner - Contributor III
Partner - Contributor III
Author

So when the admin enter the 2017 values, the code you just wrote will only give me the 2016 values. I need it to give me the 2017 values and the script to load even if just 2016 exists in the file.

surendraj
Specialist
Specialist

There are no 2017 values.please elaborate on your requirement

sfloberg
Partner - Contributor III
Partner - Contributor III
Author

When the admin enter the 2017 values - I need it to give me the 2017 values. But if only 2016 values exists I want it go give me 2016 and the script to load.

vinieme12
Champion III
Champion III

Hi,

You cannot use Aggregation functions in the Where clause. and we do not have the HAVING statement in Qlikview

So you have two options

1) load the temp table >> Then Load Max(Year) in another table and using Peek() , retrieve the value in a variable

then load Resident from the temp table where Years = vVariableCreated;

2) if you have a SQL Select statement use the Having Clause there.!

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
vinieme12
Champion III
Champion III

Example

Tab_MaxYear:

load Max(Years) as MaxYear;

LOAD * INLINE [

Years

2015

2015

2015

2016

2016

];

let vMaxYear = Peek('MaxYear',0,'Tab_MaxYear');

FACT:

LOAD * INLINE [

Days, Years

1, 2015

2, 2015

3, 2015

4, 2016

5, 2016

]

where Years = $(vMaxYear);

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
maxgro
MVP
MVP

It seems to me you only want the record with the max year

This is one of the option

X:

LOAD * INLINE [

Days, Years

1, 2015

2, 2015

3, 2015

4, 2016

5, 2016

]

;

Right Keep(X)

load max(Years) as Years

Resident X;



sfloberg
Partner - Contributor III
Partner - Contributor III
Author

Hi!
I tried this in a simple app before I try it in the correct one. But I get an error.

Bild1.PNG

Test1_tmp:

load Max(År) as MaxYear;

LOAD * INLINE [

År

2016

2016

2016

2016

2015

];

let vMaxYear = Peek('MaxYear', 0, 'Test1_tmp');

Test1:

LOAD * INLINE [

Dagar, År

1, 2016

2, 2016

3, 2016

4, 2016

5, 2015

]

Where År = $(vMaxYear);