Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
reporting_neu
Creator II
Creator II

How to get most recent date?

Hello everyone,

I have the fields "valid from" and "valid to".
The user can enter a validity date via a variable and then only the data that is valid at the time of the entered date is output. To do this, the value of the variable is simply checked to see whether it is >= "valid from" and <= "valid until".

Here is the formula:

 

if(('$(vDate)' >= ValidFrom) and ('$(vDate)' <= ValidUntil), 'Yes', 'No')

 

It can often happen that a value has more than just a "valid from" date.

Example: The user enters the date 04/01/2022 as a variable:

Value Valid From Valid Until
ABC 01/01/2022 12/31/2022
ABC 03/05/2022 12/31/2022
ABC 08/01/2022 12/31/2022

 

In this case, the formula would return a "Yes" for the first two entries.

The higher or the most recent date is always valid. So here is the second entry 03/05/2022 till 31/12/2022.

How can I include this in the formula? If I take "Max", the formula would also take a date that could be after the variable date. I also thought about calculating the difference between the variable date and the "valid from" date. But then I only have the number and I don't know how to fit that into the formula.

Do you have an idea and can you help me?

Labels (3)
0 Replies