Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Saritha077
Contributor II
Contributor II

Getting 2nd date value from the selected date in Qliksense

Hi All,

I have data like below

Saritha077_0-1732190541359.png

 

I want get get current date and previous date

created variable like below

vCurrentdate = max(date)

vprevdate=max(date,2)
but by default it is giving 2nd value, if i select something from date it will be null like below

Saritha077_1-1732190720908.png

the value should be 2024-06-28 after selecting 2024-06-30.

thanks in advance

Please help me to achieve this

Regards,

Saritha.

 

Labels (6)
2 Solutions

Accepted Solutions
Qrishna
Master
Master

Try :

  =if(GetSelectedCount(Date)=0, Date(max(Date,1), 'YYYY-MM-DD'), Date(Max({<Date = {"<$(=Only(Date))"}>} Date), 'YYYY-MM-DD'))

you can store 1st part from if() statemnt in vCurrentdate and 2nd part in variables.

if not, you can use entire if statemtn in vCurrentdate.

By default when there no selections, it shows max available date:

2493928 - Getting 2nd date value from the selected date (1).PNG

 

if a date is selected, it shows the previous max date to the selected date:

2493928 - Getting 2nd date value from the selected date (2).PNG

View solution in original post

Kushal_Chawda

@Saritha077  try below expression for previous date variable

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

View solution in original post

4 Replies
sbaro_bd
Creator III
Creator III

Hi @Saritha077 ,

Your MAX() expressions work on your active selections. No selection for your MAX() means all values available.

If you select one date, the max is applied on ONE value. So, it's normal to get a NULL from your second expression. You have to select at least two values if you want a result for your second expression.

Regards.

Qrishna
Master
Master

Try :

  =if(GetSelectedCount(Date)=0, Date(max(Date,1), 'YYYY-MM-DD'), Date(Max({<Date = {"<$(=Only(Date))"}>} Date), 'YYYY-MM-DD'))

you can store 1st part from if() statemnt in vCurrentdate and 2nd part in variables.

if not, you can use entire if statemtn in vCurrentdate.

By default when there no selections, it shows max available date:

2493928 - Getting 2nd date value from the selected date (1).PNG

 

if a date is selected, it shows the previous max date to the selected date:

2493928 - Getting 2nd date value from the selected date (2).PNG

Kushal_Chawda

@Saritha077  try below expression for previous date variable

max({<Date = {"<$(=max(Date))"}>}Date)
Saritha077
Contributor II
Contributor II
Author

Both are working fine
thanks alot

regards,

Saritha