Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
ivanaksen
Contributor III
Contributor III

Non working "Last Value"

Hello guys,

Please support with the question in touch with Last Value.

I have bellow data in the script:


CDHDR_FINAL:

Load *,

If(TCODE='ZKIT_PO01' or TCODE='ZTCS',AEDAT_CDHDR,UDATE) as PO_Appr.Date_TMP

Resident CDHDR;

Drop Table CDHDR;

LastValue:


LOAD CDHDR_KEY,

LastValue(PO_Appr.Date_TMP) as Last_PO_Apprv_Date,

LastValue(USERNAME) as Last_PO_Approver

Resident CDHDR_FINAL

Group By CDHDR_KEY;


In visualization almost everything is okay, but for some raw this rule doesn't work correctly.

For example I should have as "Last_PO_Apprv_Date" 21.09.2018,  but it shows only 17.09.2018, which is first, not last, date in the list of changes.

1.jpg

Please support and thanks in advance.


1 Solution

Accepted Solutions
andrey_krylov
Specialist
Specialist

Hi Ivan. Not sure, but maybe an ordering will help

LOAD CDHDR_KEY,

LastValue(PO_Appr.Date_TMP) as Last_PO_Apprv_Date,

LastValue(USERNAME) as Last_PO_Approver

Resident CDHDR_FINAL

Group By CDHDR_KEY

Order by USERNAME, PO_Appr.Date_TMP;

View solution in original post

5 Replies
undergrinder
Specialist II
Specialist II

Hi Ivan,

Is it important to show the last value, or you need the latest date value?

If so use the max function.

LOAD CDHDR_KEY,

Max(PO_Appr.Date_TMP) as Last_PO_Apprv_Date,

LastValue(USERNAME) as Last_PO_Approver

Resident CDHDR_FINAL

Group By CDHDR_KEY;


G.

ivanaksen
Contributor III
Contributor III
Author

Thans a lot Gabor,

"Max" is working perfectly for Date,

But the last value is necessary for the Last_PO_Approver, which is name of the person, and the "LastValue" command doesn`t work correct as well:(

agigliotti
Partner - Champion
Partner - Champion

maybe this:

tab1:

LOAD

CDHDR_KEY,

Max(PO_Appr.Date_TMP) as Last_PO_Apprv_Date

Resident CDHDR_FINAL

Group By CDHDR_KEY;

left join

load

CDHDR_KEY,

PO_Appr.Date_TMP as Last_PO_Apprv_Date,

USERNAME as Last_PO_Approver

resident CDHDR_FINAL;

I hope it helps.

andrey_krylov
Specialist
Specialist

Hi Ivan. Not sure, but maybe an ordering will help

LOAD CDHDR_KEY,

LastValue(PO_Appr.Date_TMP) as Last_PO_Apprv_Date,

LastValue(USERNAME) as Last_PO_Approver

Resident CDHDR_FINAL

Group By CDHDR_KEY

Order by USERNAME, PO_Appr.Date_TMP;

ivanaksen
Contributor III
Contributor III
Author

Thanks a lot Andrey,

It`s working,

have a nice day:)