Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
qliktoview123
Contributor II
Contributor II

Comparing the dates to get Minimum and Maximum among them

Hi,

I am trying to compare five different dates to find the minimum,maximum and variance of both of them.I am not able to compare all the dates together.Actually i am using the 'If' Statement in the expression while making a straight table

if(Date1<Date2,Date1,

if(Date1<Date3,Date1,

if(Date1<Date4,Date1,

if(Date1<Date5,Date1,

f(Date2<Date1,Date2,

if(Date2<Date3,Date2,

if(Date2<Date4,Date2,

if(Date2<Date5,Date2,

f(Date3<Date2,Date3,

if(Date3<Date1,Date3,

if(Date3<Date4,Date3,

if(Date3<Date5,Date3,

if(Date4<Date2,Date1,

if(Date4<Date3,Date1,

if(Date4<Date1,Date1,

if(Date4<Date5,Date1,

)))))   for minimum

but not getting the appropriate result.Can anybody help me out,what can i use instead of 'If' Statement.I am attaching the sample data and sample qvw and a snapshot.In the snapshot,you can see the minimum and maximum date are not correct. Please help me out.

1 Solution

Accepted Solutions
daveamz
Partner - Creator III
Partner - Creator III

Hi Atul,

First, you need to parse from string to date. To determine the min/max you can use RangeMin(), RangeMax().

Have a look at the attached document.

Regards,

David

View solution in original post

3 Replies
daveamz
Partner - Creator III
Partner - Creator III

Hi Atul,

First, you need to parse from string to date. To determine the min/max you can use RangeMin(), RangeMax().

Have a look at the attached document.

Regards,

David

Sergey_Shuklin
Specialist
Specialist

Hello, Atul!

Try this:

if(Date1>Date2 and Date1>Date3 and Date1>Date4 and Date1>Date5, Date1,

if(Date2>Date1 and Date2>Date3 and Date2>Date4 and Date2>Date5, Date2,

if(Date3>Date1 and Date3>Date2 and Date3>Date4 and Date3>Date5, Date3,

if(Date4>Date1 and Date4>Date2 and Date4>Date3 and Date4>Date5, Date4,

if(Date5>Date1 and Date5>Date2 and Date5>Date3 and Date5>Date4, Date5))))) as maximum

And vice versa for minimum.

marcus_sommer

I'm not quite sure if I had understood what do you are want to do but I would try it in this way:

rangemin(Date1,Date2,Date3,Date4,Date5)

and

rangemax(Date1,Date2,Date3,Date4,Date5)

and subtract them for the difference.

- Marcus