Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
rendiyan
Partner - Creator
Partner - Creator

[ASK] Latest transaction quantity

Dear QlikView Developer,

I have a report that have to show current transaction and latest transaction before current date, as below sample i made.

    

DateQtyDateYQtyY
4/4/2010254/3/20100
4/5/2010324/4/201025
4/6/2010 4/5/201032
4/7/2010 4/6/201032
4/8/2010254/7/201032
4/9/2010 4/8/201025
4/10/2010234/9/201025
4/11/2010 4/10/201023
4/12/2010294/11/201023

Date, and Qty column are coluns from transaction table.

And the users request to add yesterday quantity, if yesterday quantity is null then get the latest transaction quantity.

Sample above i created manually from excel to show what my users requests.

How to solve this?

Thanks,

Best Regards

5 Replies
Anonymous
Not applicable

For latest Transaction try like this?

=sum({<Date={'=$(=Date(max(Date),'DateFormat'))'}>} Qty)

For Previous Latest, like this?

=sum({<Date={'=$(=Date(max(Date)-1,'DateFormat'))'}>} Qty)

Note: Format of Date & DateFormat should be same

For You Null handling, may be like this?

=if(isnull(sum({<Date={'=$(=Date(max(Date),'DateFormat'))'}>} Qty)),

sum({<Date={'=$(=Date(max(Date)-1,'DateFormat'))'}>} Qty),    //Condition True

sum({<Date={'=$(=Date(max(Date),'DateFormat'))'}>} Qty))   //For False

sunny_talwar

Try to do this in Script or front end?

PradeepReddy
Specialist II
Specialist II

try like this..

Temp:

Load * inline

[

Date,Qty,Date

4/4/2010,25,4/3/2010

4/5/2010,32,4/4/2010

4/6/2010,,4/5/2010

4/7/2010,,4/6/2010

4/8/2010,25,4/7/2010

4/9/2010,,4/8/2010

4/10/2010,23,4/9/2010

4/11/2010,,4/10/2010

4/12/2010,29,4/11/2010

];

Test:

Load *,

if(len(trim(Qty))=0,peek(QtyY),Qty) as QtyY

resident Temp;

drop table Temp;

sunny_talwar

Slight alteration to the code:

Temp:

LOAD * inline [

Date,Qty,DateY

4/4/2010,25,4/3/2010

4/5/2010,32,4/4/2010

4/6/2010,,4/5/2010

4/7/2010,,4/6/2010

4/8/2010,25,4/7/2010

4/9/2010,,4/8/2010

4/10/2010,23,4/9/2010

4/11/2010,,4/10/2010

4/12/2010,29,4/11/2010

];

Test:

LOAD *,

  Alt(If(Len(Trim(Peek('Qty')))=0, Peek('QtyY'), Peek('Qty')), 0) as QtyY

resident Temp

Order By Date;

DROP Table Temp;


Capture.PNG

PradeepReddy
Specialist II
Specialist II

Your code works perfectly, as per the requirement..