cancel
Showing results for
Did you mean:
Contributor III

## Calculate max date difference b/w dates

HI all,

I am having data like below.

Startdate,closedate,location

1/1/2021,2/1/2021,ind

4/1/2021,10/1/2021,ind

5/1/2021,7/1/2021,UK

8/1/2021,15/1/2021,uk

Based on the above data i want to calculate the maximum date difference between the dates based on location.

Labels (1)
• ### General Question

6 Replies
MVP

Try something like this:

max(CloseDate-StartDate ) as DateDifference,

Location

From Source

Group By Location;

Contributor III
Author

I am not getting by using above script.

MVP

Consider this sample script:

SET DateFormat='D/M/YYYY';
inline [
Startdate, Closedate, Location
1/1/2021,2/1/2021,Ind
4/1/2021,10/1/2021,Ind
5/1/2021,7/1/2021,UK
8/1/2021,15/1/2021,UK]
Group By Location
;

PS: Qlik  Sense is case sensitive when it comes to values.  UK and uk are condisered as two different locations in Qlik Sense. In my sample above both UK are spelled with capital letters.

MVP

If you want to do it in the application without pre-aggregations in the data you could try an expression like this.

=aggr(MAX(Closedate-Startdate), Location)

or just

=MAX(Closedate-Startdate)

depending on how your objects are created.

Contributor III
Author

If i want to do it on front end how can we do it?

MVP

Take a look at the attached qvf file. There I show both script and in app solutions for your max difference problem.