Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Serena07
Contributor II
Contributor II

How to get data of 2 years --> Year N & Year N-1

hi, I have a field DATESTAMP and I need to limit it with 2 years of data. 

To see data only of YEAR N & YEAR N-1.

Could someone please help with this.

Labels (1)
1 Solution

Accepted Solutions
Gysbert_Wassenaar

If you're using the Data load editor you can add a Where clause to your load statement.

MyTable:
LOAD * FROM ...MySource...
WHERE Year(MyDateStampField) >= Year(Today())-1;


talk is cheap, supply exceeds demand

View solution in original post

6 Replies
Gysbert_Wassenaar

Do you want to limit the data you load into the app or do you only want to limit the data shown in a chart?

What is the value of N? Is this based on the current date or does the user select the years?

 


talk is cheap, supply exceeds demand
Serena07
Contributor II
Contributor II
Author

Hi Gysbert, thanks for responding.

I want to limit the data I load into the app. 

N is based on the current date. i.e.  at this moment - last 2 years (2020 and 2021 )

Gysbert_Wassenaar

If you're using the Data load editor you can add a Where clause to your load statement.

MyTable:
LOAD * FROM ...MySource...
WHERE Year(MyDateStampField) >= Year(Today())-1;


talk is cheap, supply exceeds demand
Serena07
Contributor II
Contributor II
Author

yes, I'm using the data load editor.

Q1. I'm writing a SQL select statement before FROM.

so what should be the syntax?

   LOAD

       A,

       B,

       DATESTAMP;

   SQL SELECT A,B,DATESTAMP

   FROM ... WHERE  Year(DATESTAMP) >= Year(Today())-1; ?

 

Q2. ALSO, This where clause [WHERE Year(MyDateStampField) >= Year(Today())-1;]  WILL I GIVE last 2 years of data or just previous year data?

Serena07
Contributor II
Contributor II
Author

Sice its >= im guessing it will take prev and current year.

but could you please clarify about the syntax.

DavidNoell
Contributor
Contributor

I am new to QlikView and working on an existing application so I apologize if this has been answered or obvious:  

I am trying to limit the data in a Pivot table.


Where do I find the Data Load Editor in QlikView?  Is it under one of the menus?  

Again,

Thank you for any help you can provide.