Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Dharanidharan_Qlik
Partner - Contributor III
Partner - Contributor III

Creating a Field with last 3 Previous Values group by TID

Hi Guys,

Want to Create a new field based on the Existing field to Show Previous 3 values as concat String

Example Input:

TID CustomerDesc Date
1Z2334 Jan 4/11/2024
1Z2334 Feb 4/12/2024
1Z2334 Apr 4/14/2024
1Z2334 Mar 4/13/2024
1Z2334 May 4/15/2024
1Z7552 Sep 4/13/2024
1Z7552 Oct 4/14/2024
1Z7552 Dec 4/16/2024
1Z7552 June 4/17/2024
1Z7552 Nov 4/15/2024

 

Expected Output;

For Each TID Get Lastest Customer Desc based on the recent Date and Followed by Previous date Customer Desc

TID Last_3_History_CustomerDesc_Based on Date
1Z2334 May>Apr>Mar
1Z7552 Jun>Dec>Nov
3 Replies
Chanty4u
MVP
MVP

Try this

Concat({<TID = P(TID), Date = {"<=$(=Max(Date))"}>} CustomerDesc, '>') 

Dharanidharan_Qlik
Partner - Contributor III
Partner - Contributor III
Author

hi @Chanty4u 

Thanks,, It's not working It shows all values in the column and randomly Order.. 

 

If we get something in Backend to Load the last 3 values for all TID as separate tables, it will work

marcus_sommer

In each case you will need an appropriate sorting-logic. This information might be applied as third parameter within the concat() maybe with -Date if it has the wanted information.

A direct limitation to 3 values within the aggregation is probably difficult to impossible. But you may just take the entire result-string and cutting the wanted part, maybe per: left(String, index(String, '>, 3) - 1)