Qlik Community

Ask a Question

New to Qlik Sense

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

Announcements
Welcome to our newly redesigned Qlik Community! Read our blog to learn about all the new updates: READ BLOG and REPORTED ISSUES
cancel
Showing results for 
Search instead for 
Did you mean: 
Contributor III
Contributor III

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
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
Creator
Creator

Try This

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

Contributor III
Contributor III

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.

Partner
Partner

maybe with the below expression for last shipping date:

firstsortedvalue(  Date, -Date )

and for previous last shipping:

firstsortedvalue(  Date, -Date, 2)

Specialist
Specialist

Try this:

For last date: Date(Max(Date))

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

View solution in original post

Contributor III
Contributor III

Thanks Tim!

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

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.