Qlik Community

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
Customer & Partners, DEC. 9, 11 AM ET: Qlik Product & Strategy Roadmap Session: Data Analytics REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
asmithids
Partner
Partner

Previous() Function Not Showing Correct Previous Values

Hello,

I'm trying to create a field in the load script that has the previous value of another field (i.e. "Reserve Amount").  Below is the load script.   The result of the load creates the "PreviousReserve" field that is just the same number down the column.  See attached spreadsheet of an export of the Qlik Sense table.  I've reviewed other posts on this topic.  They seem to address Previous function issues where there is just one dimension.  My issue has 4 dimensions.  I'm assuming this is the area why the Previous function is not working, but I'm not 100% sure.  

Any help would be very much appreciated! 

 

Load Script:

ReserveAcrossTimeData:
LOAD
    "Reserve Type",
    "Change Date",
    "Reserve Amount",
    "claimid",
    "ReserveHistoryID"
FROM [lib://QVD /ReserveAcrossTimeData.qvd] (qvd);

PreviousReserve:
Load claimid,
Previous("Reserve Amount") As "PreviousReserve" 

Resident ReserveAcrossTimeData
Order by ReserveHistoryID,"Change Date",claimid,"Reserve Type" desc;

Labels (1)
2 Replies
marcus_sommer
MVP & Luminary
MVP & Luminary

The number of fields within a load with previous() isn't important but the order by statement is essential which is executed from left to the right. Therefore I suggest to check this order if it really matched to your expectation.

- Marcus

asmithids
Partner
Partner
Author

Hi Marcus,

Thank you.   The order by statement in the load script has the fields that make up a unique record per row  (i.e.ReserveHistoryID,"Change Date",claimid,"Reserve Type" as the sort sequence for the Previous("Reserve Amount") calculation.  The resulting previous reserve amount is the same number for each row as show in the attached spreadsheet.  Not sure why this is happening.  Have you seen this issue before?  

Thanks again,