Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Highlighted
qlikeers
New 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
timpoismans
Valued Contributor

Re: Last two shopping days

Try this:

For last date: Date(Max(Date))

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

6 Replies
priyalvp24
Contributor

Re: Last two shopping days

Try This

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

qlikeers
New Contributor III

Re: Last two shopping days

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

Re: Last two shopping days

maybe with the below expression for last shipping date:

firstsortedvalue(  Date, -Date )

and for previous last shipping:

firstsortedvalue(  Date, -Date, 2)

timpoismans
Valued Contributor

Re: Last two shopping days

Try this:

For last date: Date(Max(Date))

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

qlikeers
New Contributor III

Re: Last two shopping days

Thanks Tim!

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

timpoismans
Valued Contributor

Re: Last two shopping days

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.