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

Get last date and previous one

Hello,

I am having trouble trying to solve the following:

I have a table with clients id and two columns, the first with the selected date (selected on the filter) and the column should include the date just previous of the selected one.

id_storedate 1date 2
411/07/2014-
411/08/201411/07/2014
411/09/201411/08/2014
If on my Qlik View I select the filter that contains the date, and I select 11/08/2014, what I want to obtain is the following:
id_storedate 1date 2
411/08/201411/07/2014

Is this clear??

I hope you can help me!!

regards,

4 Replies
tcullinane
Creator II
Creator II

Not sure why you want this to display, you might be better having the previous date as a variable based on the selection if you mean to do other calculations based on it, but if you use a chart straight table you can have the third column as an expression :

=[date1]-1

Not applicable
Author

HI, I mean to do some calculus. In summary what I want is the following:

storeproducts sold on date 1 product sold on date 2

Date 1 being the selcted one, and date two being the previous.

The catch on this is also that if I have more than two dates  and i SElect the last, and just the previous dint sold the product, I need to pick the  last date that this store sold the product without being the selected one.

It is confusing to explain, so please let me know if you understand.

jagan
Luminary Alumni
Luminary Alumni

Hi,

Try this in script

LOAD

*,

If(Previous(id_store) = id_store, Previous(date1)) AS date2

FROM DataSource

order by id_store;

Now use date2 column in chart.

Regards,

jagan.

tcullinane
Creator II
Creator II

It will depend on how your data is loaded alright, If you are loading a table with [Store_ID,Sale_Date,Product,Amount,etc,...] an expression such as:

above(Sales_Date) with set analysis or if statement to limit the store and product should work.