Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Show only a few years

Hello everyone!

years.png

This are all the years from my data. Jaar is the Dutch word for year.

This is in my script:

LOAD Number,
(
JAAR+2000) as JAAR,
FROM
\source
(
qvd);

My question is: Can I said in my data that I only want to see the max year, and 3 other. In this case: 2015, 2014, 2013 and 2012?

Or is this impossible.

I know I ask something like this in another post, but this is an better one.

Thanks!

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

If you want to just show Latest 4 years in your list box .

Then just create a variable

Var1=max({1}JAAR)-4

then select list box and use expression in place of field name

in expression write

=if(JAAR>=Var1,JAAR)

it will show you four latest year.

If this is not your requirement let me know .

Thanks

BKC

View solution in original post

8 Replies
jpenuliar
Partner - Specialist III
Partner - Specialist III

Try Preceding Load:

Load *

Where JAAR >= '2012;'

LOAD Number,
(
JAAR+2000) as JAAR,
FROM
\source
(
qvd);

Gysbert_Wassenaar

If you don't want to load the data of earlier years you can use a where clause:


LOAD Number,
(
JAAR+2000) as JAAR,
FROM \source (qvd)

WHERE JAAR >=12;


If you do want to load the data, but want to filter it in the front end there are several ways. You could simply select the years you want to see. This is the easiest solution. You could create a bookmark for that selection so you can easily return to that selection.


talk is cheap, supply exceeds demand
Not applicable
Author

Hi Lieko

You could add a simple where condition on the load, or create something a bit more dynamic based on your data.

Something like the below should work.

MaxYear:

LOAD Distinct
Max((
JAAR+2000)) as JAAR,
FROM
\source
(
qvd);

Let vMaxYear =Peek('JAAR')

Drop table MaxYear;

LOAD Number,
(
JAAR+2000) as JAAR,
FROM
\source
(
qvd)

Where (JAAR+2000)  > $(vMaxYear-3);

Hope that helps

Joe

Not applicable
Author

Hi lieko,

You can write below code in you script editor while loading your data.


LOAD *,
(
JAAR+2000) as JAAR,
FROM \source (qvd)

WHERE JAAR >='2012';


Regards,

Priyanka

jsanchezh
Partner - Creator
Partner - Creator

You can try something like this:

Year_start = year(yearstart(AddMonths(today(), -36))); //-36 means the number of years from now in months 12x3=36

Year_today = year(yearstart(AddMonths(today(), 0)));

Jaar:

LOAD  Number,

  (Jaar+ 2000) as Jaar

FROM \source

where (Number + 2000)>='$(Year_start)' and (Number + 2000)<='$(Year_today)';

Hope that helps

Anonymous
Not applicable
Author

If you want to just show Latest 4 years in your list box .

Then just create a variable

Var1=max({1}JAAR)-4

then select list box and use expression in place of field name

in expression write

=if(JAAR>=Var1,JAAR)

it will show you four latest year.

If this is not your requirement let me know .

Thanks

BKC

Not applicable
Author

Thanks alll! The option of BKC is the easiest one for me. It was correct!

Not applicable
Author

And if I want  to show the years 2010, 2011, 2012, 2013?

Than can I not use max year