Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Maximum date minus Minimum date

Hello,

             i have a table like this

Entry no         Date

2                    25/11/2011

2                    30/11/2011

2                    5/12/2011

3                    24/11/2011

3                    28/11/2011

I want to get Max(Date)- Min(Date) for every entry number in a list box how to get it?

i have already tried aggr(Max(Date)-Min(Date),Entry no)

but its not working

any suggestions?

thanks

Harleen

1 Solution

Accepted Solutions
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

     Try this in chart.

     Max(Total <EntryNo> Date) -  Min(Total <EntryNo> Date)

     For example refere the attached file.

Rehards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!

View solution in original post

5 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

     Try this in chart.

     Max(Total <EntryNo> Date) -  Min(Total <EntryNo> Date)

     For example refere the attached file.

Rehards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
SunilChauhan
Champion II
Champion II

load like below

tab1:

Load * inline [

Entry no    ,     Date

2         ,        25/11/2011

2        ,            30/11/2011

2        ,            5/12/2011

3       ,             24/11/2011

3       ,             28/11/2011

];

Load

makedate(subfield(Date,'/',3),subfield(Date,'/',2),subfield(Date,'/',1)) as Datenum,

Date,

[Entry no],

1 as flag

resident tab1;

drop table tab1;

and then

use this

Max(Datenum)-Min(Datenum)

inplace of  aggr(Max(Date)-Min(Date),Entry no)


Sunil Chauhan
Miguel_Angel_Baeyens

Hi Harleen,

Use the following script:

DataTemp:

LOAD * INLINE [

Entry no, Date

2, 25/11/2011

2, 30/11/2011

2, 05/12/2011

3, 24/11/2011

3, 28/11/2011

];

DataDiff:

LOAD "Entry no",

           Max(Date) - Min(Date) AS DateDiff

RESIDENT DataTemp

GROUP BY "Entry no"

ORDER BY "Entry no", Date ASC;

This will perform faster, because you only need to use the field DateDiff in the listbox.

According to the script above, your code will work

=Aggr(Max(Date) - Min(Date), [Entry no])

Hope that helps.

Miguel

swuehl
MVP
MVP

Have you checked that your DateFormat is 'DD/MM/YYYY' and not 'MM/DD/YYYY' or something else?

Not applicable
Author

Thanks kaushik it worked perfectly in chart.

Miguel I wanted to apply this code in fron end not in the script.

your answer is correct .