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: 
qlikeers
Creator II
Creator II

Last two shopping days

Hi!

I can not cope with writing a set analysis that will show me the last two shopping dates (for each customer).

Data scheme as in the attachment.

I would like to get very simple table:

CustIDLast date (from sales)Last but one date  (from sales)
C10001-08-201831-07-2018
C105......
.........

If I do it in this way:

max({<[Date={"<$(=max([Date]))"}>} [Date])

It only works for the client I choose with the filter. How to make the dates correct in the entire table - without selecting clients?

1 Solution

Accepted Solutions
timpoismans
Specialist
Specialist

Try this:

For last date: Date(Max(Date))

For last but one date: Date(Max(Date,2))

View solution in original post

6 Replies
priyalvp24
Creator
Creator

Try This

DateField={"<=$(=max(date(addmonths(DateField, 0))))>=$(=max(date(addmonths(DateField, 0)-2)))"}

qlikeers
Creator II
Creator II
Author

It does not work for me. I do not know if I have explained the case well. Each customer will have different dates of the last purchase and the last but one.

agigliotti
Partner - Champion
Partner - Champion

maybe with the below expression for last shipping date:

firstsortedvalue(  Date, -Date )

and for previous last shipping:

firstsortedvalue(  Date, -Date, 2)

timpoismans
Specialist
Specialist

Try this:

For last date: Date(Max(Date))

For last but one date: Date(Max(Date,2))

qlikeers
Creator II
Creator II
Author

Thanks Tim!

It looks like it was simpler than I could have imagined!

timpoismans
Specialist
Specialist

You're welcome!

I had the exact same issue and indeed, the solution was simpler than I had thought at the time.

Glad I could help.

Kind regards,

Tim P.