Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
Could you please help me on the same
Try something like this:
Load
max(CloseDate-StartDate ) as DateDifference,
Location
From Source
Group By Location;
Thanks for the reply.
I am not getting by using above script.
Consider this sample script:
SET DateFormat='D/M/YYYY';
LOAD MAX(Closedate-Startdate) as DateDifference, Location
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.
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.
Thanks for reply.
If i want to do it on front end how can we do it?
Take a look at the attached qvf file. There I show both script and in app solutions for your max difference problem.