Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
nikhilgarg
Specialist II
Specialist II

WHen does the Previous() used??

HEy,

I was going through Previous(). I tried to use it in Expression Tab but there no Previous() is defined. But when i used Previous in Load script then there it is defined.

Does that mean i can use Previous() only in Load script or while loading data ??

Please help and also tell me the scenario where it is used most often.

Thanks

4 Replies
kushalthakral
Creator III
Creator III

Dear Nikhil

Previous and Peek are two variables which always used in script not in the expressions

as both these function refers to the table and u do not have table during expression

Previous is always used to refer last loaded data in the table

Regards

Kushal Thakral

ashfaq_haseeb
Champion III
Champion III

Hi,

Check if this helps

Peek() vs Previous() – When to Use Each

regards

ASHFAQ

jagan
Luminary Alumni
Luminary Alumni

Hi Nikhil,

Note: Previous() is a script function not the chart function.

Sometimes during loading we need the values of certain columns of previous row in current row, for this scenario the Previous() is useful.  One best example is previous day sales, check below example

Date          Sales

1/1/2014     100

1/2/2014     200

1/3/204       150

Suppose if you want Previous day sales like below

Date          Sales     Previous Day Sales

1/1/2014     100          -

1/2/2014     200         100                    

1/3/204       150         200                    

For above we will use Previous() like below

LOAD

Date,

Sales,

Previous(Sales) AS PreviousDaySales

FROM DataSource;

Hope this  helps you.

Regards,

jagan.

Siva_Sankar
Master II
Master II

Hi Nikhil,

Previous() function is not a chart function, it is a script function. If you want to achieve the functionality of previous() in chart expression then you can use above() function in expression. Find the attached document. will help you to use the previous() functionality in charts using above() function.