# New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Highlighted Not applicable

## calculate the time gap between the dates group by another dimension

NameDateEventTime Gap
A04/01/2012TEXT
A03/05/2013TEXT
A04/12/2013TEXT*
B01/01/2016TEXT
C09/27/2015TEXT
C10/04/2017TEXT

I want to calculate the time gap between the dates by Name.

for * marked cell, fill the cell with the number value(number of days difference between 04/12/2013 and 03/05/2013).

for Name B, there is just one date value, so just leave it Time Gap cell as '-'

Could anybody help me??

Tags (5)
1 Solution

Accepted Solutions
Valued Contributor

## Re: calculate the time gap between the dates group by another dimension

How about using this in the script?

If(Name=peek(Name),Date-peek(Date),'') as [Time Gap]

3 Replies
Valued Contributor

## Re: calculate the time gap between the dates group by another dimension

How about using this in the script?

If(Name=peek(Name),Date-peek(Date),'') as [Time Gap]

Valued Contributor

## Re: calculate the time gap between the dates group by another dimension

What will be the difference between third A and 2nd A???

LOAD Name,

Date,

Event,

if(Peek(Name)=Name,(Date)-Peek(Date),'-') as Gap

FROM

(html, codepage is 1252, embedded labels, table is @1); Not applicable

## Re: calculate the time gap between the dates group by another dimension

they are the same, 1st,2nd and 3rd A.

Thank you 