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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
doublepsa
Contributor II
Contributor II

Min between two dates

Good afternoon, folks!

I'm trying to calculate the minimum between two dates in a KPI script but I'm facing some errors. 

I tried the following: 

=min(data_final+tamanho_durante, Date#('18/02/2021','DD/MM/YYYY'))
 
But Qlik can't calculate this minimum.
 
When I calculate only data_final+tamanho_durante or Date#('18/02/2021','DD/MM/YYYY'), the result is the expected, so I guess the problem is with the min function.
 
data_final is a variable in format date 'DD-MM-YYYY' and tamanho_durante is a integer.
 
Could you please help me? Thanks in advance!
Labels (1)
1 Solution

Accepted Solutions
doublepsa
Contributor II
Contributor II
Author

Hi, @QFabian , I tried what you suggested but where Date=data_final+tamanho_durante, but I couldn't reach the expected result...

Fortunately, I was able to find the solution using RangeMin instead of Min:

=RangeMin(Date#('18/02/2021','DD/MM/YYYY'),num(data_final)+tamanho_durante)

Thanks for your support!

View solution in original post

4 Replies
QFabian
MVP
MVP

Hi  @doublepsa , please try this :

=Date(min(num(data_final)+tamanho_durante), 'DD/MM/YYYY')

Greetings!! Fabián Quezada (QFabian)
did it work for you? give like and mark the solution as accepted.
doublepsa
Contributor II
Contributor II
Author

Hi @QFabian this works here, Qlik understands it and gives back the correct date.

But the problem is that I want to calculate the mininum date between this variable date (data_final+tamanho_durante) and a fixed date '18/02/2021'.

Do you know how I could do this?

QFabian
MVP
MVP

Hi @doublepsa , i just created this and works, please check your date separator, in my case '-'

QFabian_0-1614097488100.png

 

Greetings!! Fabián Quezada (QFabian)
did it work for you? give like and mark the solution as accepted.
doublepsa
Contributor II
Contributor II
Author

Hi, @QFabian , I tried what you suggested but where Date=data_final+tamanho_durante, but I couldn't reach the expected result...

Fortunately, I was able to find the solution using RangeMin instead of Min:

=RangeMin(Date#('18/02/2021','DD/MM/YYYY'),num(data_final)+tamanho_durante)

Thanks for your support!