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: 
Aldemarprins4
Contributor III
Contributor III

Create Pairs

Hi everyone,
i have the following problem.

I would like to make pairs of the following form:

 

Arrival Stage Departure
02/11/2021 13:31:27 1. Process 02/11/2021 14:11:38
02/11/2021 14:12:02 1. Process 02/11/2021 14:12:03
02/11/2021 14:18:27 2 Distribucion 02/11/2021 14:18:28
02/11/2021 14:50:42 1. Process 02/11/2021 15:03:51
02/11/2021 15:10:41 2 Distribucion 02/11/2021 15:10:42
     

 

pairs  should be as follows:

Pair Arrival Stage Departure
1 02/11/2021 13:31:27 1. Process 02/11/2021 14:11:38
1 02/11/2021 14:12:02 1. Process 02/11/2021 14:12:03
1 02/11/2021 14:18:27 2 Distribucion 02/11/2021 14:18:28
2 02/11/2021 14:50:42 1. Process 02/11/2021 15:03:51
2 02/11/2021 15:10:41 2 Distribucion 02/11/2021 15:10:42
       

 

 Every time find a stage 2 Distribution before stage 1. Process a pair must be made

 

Thank you

 

2 Solutions

Accepted Solutions
MarcoWedel

maybe like this?

LOAD Arrival, 
     Stage, 
     Departure,
     Alt(Peek(Pair),1)-(Stage='1. Process' and Previous(Stage)='2 Distribucion') as Pair
FROM [https://community.qlik.com/t5/QlikView-App-Dev/Create-Pairs/m-p/1867660](html, codepage is 1252, embedded labels, table is @1);

 

hope this helps

Marco

View solution in original post

Aldemarprins4
Contributor III
Contributor III
Author

Thank you very much, so far it works for me, I am going to try other similar cases but where there are more stages 1. Process.

 

You saved my life

 

View solution in original post

4 Replies
MarcoWedel

maybe like this?

LOAD Arrival, 
     Stage, 
     Departure,
     Alt(Peek(Pair),1)-(Stage='1. Process' and Previous(Stage)='2 Distribucion') as Pair
FROM [https://community.qlik.com/t5/QlikView-App-Dev/Create-Pairs/m-p/1867660](html, codepage is 1252, embedded labels, table is @1);

 

hope this helps

Marco

Aldemarprins4
Contributor III
Contributor III
Author

Thank you very much, so far it works for me, I am going to try other similar cases but where there are more stages 1. Process.

 

You saved my life

 

MarcoWedel

glad it worked.

Please close your thread by accepting a solution once your tests are finished.

thanks

Aldemarprins4
Contributor III
Contributor III
Author

Hello friend,

I have a problem and it is that by including more data it is not creating several pairs like this in the table but rather it creates a single one, in that case how could it be solved?

 

air Arrival Stage Departure Trx
1 02/11/2021 13:31:27 1. Process 02/11/2021 14:11:38 C01
1 02/11/2021 14:12:02 1. Process 02/11/2021 14:12:03 C01
1 02/11/2021 14:18:27 2 Distribucion 02/11/2021 14:18:28 C01
2 02/11/2021 14:50:42 1. Process 02/11/2021 15:03:51 C01
2 02/11/2021 15:10:41 2 Distribucion 02/11/2021 15:10:42 C01
3 03/11/2021 13:31:27 1. Process 03/11/2021 14:11:38 C02
3 03/11/2021 13:31:27 1. Process 03/11/2021 14:12:03 C02
3 03/11/2021 14:18:27 2 Distribucion 03/11/2021 14:18:28 C02