Qlik Community

QlikView Layout & Visualizations

Discussion Board for collaboration on QlikView Layout & Visualizations.

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
balkumarchandel
Valued Contributor II

Re: Show only a few years

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

8 Replies
jpenuliar
Valued Contributor III

Re: Show only a few years

Try Preceding Load:

Load *

Where JAAR >= '2012;'

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

Re: Show only a few years

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

Re: Show only a few years

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

Re: Show only a few years

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
Contributor

Re: Show only a few years

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

balkumarchandel
Valued Contributor II

Re: Show only a few years

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

Re: Show only a few years

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

Not applicable

Re: Show only a few years

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

Than can I not use max year

Community Browser