Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

get latest data

Hi,

How to get latest 5 years data dynamically. how to restrict in script.

Regards,

krishna

6 Replies
datanibbler
Champion
Champion

Hi,

do you have some date_field?

Then you can use the Month() and Year() functions to construct other dimensions out of that.

You can then use a WHERE() clause with some expression based on that (like >> Year(date) >= Year(Today())-5 <<

HTH

PrashantSangle

Hi,

Write

Where Year(dateField)> AddYear(Year(Today()),-5)

Regards,

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
buzzy996
Master II
Master II

Simply u can use this in end of ur  table name in ur script:

Where Year(NOW())-5

simsondevadoss
Partner - Creator III
Partner - Creator III

where YEAR(Today())-5;

Not applicable
Author

Hi,

Try like this type of script.

A:

LOAD * INLINE [

    Year, Sales, Category

    2015, 50000, A

    2014, 60000, A

    2013, 30000, A

    2012, 25000, A

    2015, 70000, B

    2014, 80000, B

    2013, 30000, B

    2012, 95000, B

    2015, 50000, C

    2014, 70000, C

    2013, 30000, C

    2012, 35000, C

];

temp:

LOAD

   Year(Today())-3   as     yr

Resident A;

Not applicable
Author

Hi Krishna

Try this, i use it my self;

where DATEFIELD >= (num(Today())-1825)  // 5 year back from current day

This way you will have a full set of data going back 5 years all time.

Best regards,

Teis