Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Years

I have data with many years, but I only want to see the max year and max year - 1, max year - 2, max year - 3.

Can I make this in my script or on another place?

Thanks

1 Solution

Accepted Solutions
sunny_talwar

LOAD Number,
     
Year
FROM Source

Where Year < 2026;

View solution in original post

12 Replies
Anonymous
Not applicable
Author

I would do it in the load script using a suitable WHERE when loading the data.

buzzy996
Master II
Master II

u can do in both the ways,

in ur script.

where yeardatefield>=(max(yeardatefield) -3)

sunny_talwar

You can restrict it within the script by creating a variable vMaxYear

Data:

LOAD fieldNames,

          Year

FROM yourSource;

MaxYear:

LOAD Max(Year) as maxYear

Resident Data;

LET vMaxYear = Peek('maxYear');

DataTable:

NoConcatenate

LOAD *

Resident Data

Where Year >= ($(vMaxYear) - 3);

DROP TABLES Data, MaxYear;

HTH

Best,

Sunny

Not applicable
Author

Thanks all!

But I now I don't want this, but in my data I have the years 2026,2088 can I exclude them?

sunny_talwar

You can do this to exclude anything after the year 2026


Where Year < 2026;


or you can exclude anything from next year forward:

Where Year <= Year(Today());

HTH

Best,

Sunny

Not applicable
Author

Oke and this : Where Year < 2026; must I copy past in my script?

Not applicable
Author

LOAD Number,
     
Year
FROM
Source

Or must i copy past it behind Year?

sunny_talwar

Ya i would paste it after the FROM/Resident statement in the table from which you want to exclude Year 2026 and beyond.

sunny_talwar

LOAD Number,
     
Year
FROM Source

Where Year < 2026;