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

Try with applying single quotes

Where År = '$(vMaxYear)';

swuehl
MVP
MVP

Stephanie, your script does not fail if I run it. It's just returning an empty table with your two fields.

Are you using some more code?

If no records exists in your loaded table, you can't access any records in subsequent LOAD statements, right?

Is this maybe causing an error in your reload?

Stephanie Floberg wrote:

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.

Have you tried what maxgro suggested?

edit: If you don't like the extra table, then you can drop it:

X:

LOAD * INLINE [

Days, Years

1, 2015

2, 2015

3, 2015

4, 2016

5, 2016

]

;

MaxYear:

Right Keep(X)

load max(Years) as Years

Resident X;

Drop Table MaxYear;