Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikWorld 2020: Join us May 11 - 14, 2020 in Phoenix, AZ. Register early and save $400. Learn More
Highlighted
krishna4bo
Contributor

get latest data

Hi,

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

Regards,

krishna

Tags (3)
6 Replies
datanibbler
Esteemed Contributor

Re: get latest data

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

Re: get latest data

Hi,

Write

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

Regards,

Great dreamer's dreams never fulfilled, they are always transcended.
buzzy996
Honored Contributor II

Re: get latest data

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

Where Year(NOW())-5

Partner
Partner

Re: get latest data

where YEAR(Today())-5;

Not applicable

Re: get latest data

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

Re: get latest data

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