# New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
Save \$300 - Register for QlikWorld (formerly Qonnections) by January 31st: Learn More
Contributor II

## max of date help

Hi,

I have dates in [Report Date] field like below

Report Date

11/09/2019

21/09/2019

30/09/2019

I have to compare first Max date and Second Max date results

First Max Date:

COUNT({<[Report Date]={'\$(=Max(Date([Report Date],'DD/MM/YYYY')))'}>}DISTINCT [Element Name])

1 Solution

Accepted Solutions
MVP

## Re: max of date help

Try this

``Count({<[Report Date] = {"\$(=Date(Max({<[Report Date] = {[<=\$(=Date(Max([Report Date]), 'DD/MM/YYYY'))]}>} [Report Date], 2), 'DD/MM/YYYY'))"}>} DISTINCT [Element Name])``
6 Replies

## Re: max of date help

Perhaps this? COUNT({<[Report Date]={'\$(=Max(Date([Report Date],'DD/MM/YYYY'), 2))'}>}DISTINCT [Element Name])
Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
Highlighted
Partner

## Re: max of date help

Max has optional Rank Variable. So like this

COUNT({<[Report Date]={'\$(=Max(Date([Report Date],'DD/MM/YYYY'),2))'}>}DISTINCT [Element Name])

MVP

## Re: max of date help

I would put Max before Date in the set modifier even for max date

``Count({<[Report Date] = {"\$(=Date(Max([Report Date]), 'DD/MM/YYYY'))"}>} DISTINCT [Element Name])``

and then the second max date count would be

``Count({<[Report Date] = {"\$(=Date(Max([Report Date], 2), 'DD/MM/YYYY'))"}>} DISTINCT [Element Name])``
Contributor II

## Re: max of date help

The expression is working fine when I haven't selected any date. But when I selected 21/10/2019 then the previous date 11/10/2019 need to get. Same like when there are multiple dates from the selected date to previous date has to be visible.

Here the issue is when I have selected 21/10/2019  its showing blank without any date select its working.

Contributor II

## Re: max of date help

The expression is working fine when I haven't selected any date. But when I selected 21/10/2019 then the previous date 11/10/2019 need to get. Same like when there are multiple dates from the selected date to previous date has to be visible.

Here the issue is when I have selected 21/10/2019  its showing blank without any date select its working.

``Count({<[Report Date] = {"\$(=Date(Max({<[Report Date] = {[<=\$(=Date(Max([Report Date]), 'DD/MM/YYYY'))]}>} [Report Date], 2), 'DD/MM/YYYY'))"}>} DISTINCT [Element Name])``