Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I would like to return the previous value (grouped by product). AND I would like to do it in load script. I have a partial solution, but it is not very elegant or efficient. How this could be done?
Thanks!
Look at peek and previous function.
Regards
ASHFAQ
But peek gets only the row (and table) as input argument. So it doesn't work when the product changes, right?
"Peek() is used in the script, pick() - on the front end. From Help:
peek(fieldname [ , row [ , tablename ] ] )
Returns the contents of the fieldname in the record specified by row in the internal table tablename. Data are fetched from the associative QlikView database.
Fieldname must be given as a string (e.g. a quoted literal).
Row must be an integer. 0 denotes the first record, 1 the second and so on. Negative numbers indicate order from the end of the table. -1 denotes the last record read.
If no row is stated, -1 is assumed.
Tablename is a table label, see Table Labels, without the ending colon. If no tablename is stated, the current table is assumed. If used outside the load statement or referring to another table, the tablename must be included. "
Hi user,
PFA. is this is what you are looking for?
Regards
KC
Change the line to.
if(Product= previous(Product),previous(Price),'') as Pre_price
Regards
KC
Hi user,
PFA updated one.
Regards
KC
Initial:
Load DATE(DATE#(DATE,'M.D.YYYY')) AS DATE,PRODUCT,PRICE INLINE [
DATE,PRODUCT,PRICE
1.1.2014,A,30
1.2.2014,A,30
1.3.2014,A,29
1.1.2014,B,43
1.2.2014,B,43
1.3.2014,B,40 ];
NoConcatenate
Final:
Load DATE,PRODUCT,PRICE,If(PRODUCT = Previous(PRODUCT),PRICE) as PREV_PRICE Resident Initial Order by PRODUCT,DATE;
Drop table Initial;
Of course! It's so simple, thanks!