Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
asmithids
Partner - Creator II
Partner - Creator II

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

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 - Creator II
Partner - Creator II
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,