Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Creating History table

Problem : Show Orders History

I have Orders table with Fields of Order_Item_Num,Order_Num,Order_Date,Order_Item_Quantity,Order_Item_Price,Order_Item_Price_Total,

What I need to do is to show the last or previous info for each Order, in any date selected.

The Item can be twice a day or each day.

Means :

The last Order_Item_Quantity,Order_Item_Price,Order_Item_Price_Total

I know that I need to crate a history table connected to the Orders t dayable.

Please advice.

Jacov

3 Replies
yblake
Partner - Creator II
Partner - Creator II

Hello,

some hints for you :

to get previous order line :

left join (OrdersHistory) load

Order_Num,

Order_Item_Num,

if(Order_Num = previous(Order_Num), previous(Order_Item), null()) as Previous_Item

resident OrdersHistory

order by Order_Num, Order_Item_Num;

to get last order line :

left join (OrdersHistory) load

Order_Num,

LastValue(Order_Item_Num) as Last_Item

resident OrdersHistory

Order by Order_Num, Order_Item_Num

Group By Order_Num;

Hope it helps.

Not applicable
Author

Yves,

It doesn't help me.

I need to get the info of the previous order, of the same item.

Since Order_Num = previous(Order_Num) will always be NO, it will always get NULL.

Jacov

Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Jacov,

try function FirstSortedValue - looks like your problem could be solved with it.

Oleg