Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Calcular o tempo entre a hora da chegada pela hora da próxima saída

Bom dia pessoal.

Como posso calcular o horário da chegada pela próxima saída?

Segue tabela em anexo como exemplo.

Exemplo: 07:15 - 07:01 = 00:14

PosSaídaChegada
15:207:01
17:159:25
110:2012:50
113:1013:10
113:2515:53
116:5019:33
120:2022:01
122:1722:37
1 Solution

Accepted Solutions
fernando_tonial
Partner - Specialist
Partner - Specialist

Olá,

Veja exemplo.

Dados:

LOAD Pos, Saída, Chegada, If(Pos=Peek('Pos'), Interval(Saída-Peek('Chegada')),Null()) as Diferença INLINE [

    Pos, Saída, Chegada

    1, 5:20, 7:01

    1, 7:15, 9:25

    1, 10:20, 12:50

    1, 13:10, 13:10

    1, 13:25, 15:53

    1, 16:50, 19:33

    1, 20:20, 22:01

    1, 22:17, 22:37

];

Qlikfique-se.

Tonial.

Don't Worry, be Qlik.

View solution in original post

8 Replies
lucianosv
Specialist
Specialist

Boa tarde.

Com os registros nessa ordem, você calcula em script:

Saída - Previous(Chegada) as  Variação

Você tem que garantir a ordem dos registros, pois o previous pega a linha naterior

fernando_tonial
Partner - Specialist
Partner - Specialist

Olá,

Veja exemplo.

Dados:

LOAD Pos, Saída, Chegada, If(Pos=Peek('Pos'), Interval(Saída-Peek('Chegada')),Null()) as Diferença INLINE [

    Pos, Saída, Chegada

    1, 5:20, 7:01

    1, 7:15, 9:25

    1, 10:20, 12:50

    1, 13:10, 13:10

    1, 13:25, 15:53

    1, 16:50, 19:33

    1, 20:20, 22:01

    1, 22:17, 22:37

];

Qlikfique-se.

Tonial.

Don't Worry, be Qlik.
lucianosv
Specialist
Specialist

Segue exemplo:

Not applicable
Author

Funcionou com os dados que mandei com 1 posição, porem existem mais de 1 posição.

Exemplo em anexo:

PosSaídaChegada
15:207:01
110:2012:50
113:1013:10
113:2515:53
116:5019:33
120:2022:01
122:1722:37
26:008:24
28:0010:20
211:1013:34
213:3414:10
215:5016:10
216:1018:59
219:3021:13
222:0023:12
lucianosv
Specialist
Specialist

Olhe o meu exemplo. Está correto.

fernando_tonial
Partner - Specialist
Partner - Specialist

Só fazer a verificação da posição.

Dados:

LOAD Pos, Saída, Chegada, If(Pos=Peek('Pos'), Interval(Saída-Peek('Chegada')),Null()) as Dif INLINE [

    Pos, Saída, Chegada

    1, 5:20, 7:01

    1, 7:15, 9:25

    1, 10:20, 12:50

    1, 13:10, 13:10

    1, 13:25, 15:53

    1, 16:50, 19:33

    1, 20:20, 22:01

    1, 22:17, 22:37

    2, 6:00, 8:20

    2, 8:24, 10:20

    2, 11:10, 13:34

    2, 13:34, 14:10

    2, 15:50, 16:10

    2, 16:10, 18:59

    2, 19:30, 21:13

    2, 22:00, 23:12  

];

Qlikfique-se.

Tonial.

Don't Worry, be Qlik.
Not applicable
Author

Correta, obrigado!!!

Not applicable
Author

Correto!! Obrigado!!