Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Vinerc
Contributor II
Contributor II

Intermatch count with several lines

Hello all,

I'm trying to join two tables but I'm having difficult because one of the tables have about 20 million lines (passengers table) and I'm creating more lines with my join. I have two tables: Passengers and Travels. I want to get the count of passengers in each travel and keep the travels table and drop the passengers table.

Travels:

Load * inline

[

Car,StartTime,EndTime, Line

1,01/01/2020 08:00:00, 01/01/2020 08:40:00, 100

1,01/01/2020 08:40:00, 01/01/2020 09:20:00, 100

1,01/01/2020 09:20:00, 01/01/2020 10:00:00, 100

2,01/01/2020 08:00:00, 01/01/2020 08:40:00, 101

2,01/01/2020 08:40:00, 01/01/2020 09:20:00, 101

2,01/01/2020 09:20:00, 01/01/2020 10:00:00, 101

];

Passengers:

Load * inline

[

Car,Time

1,01/01/2020 08:10:00

1,01/01/2020 08:50:00

1,01/01/2020 09:10:00

2,01/01/2020 08:10:00

2,01/01/2020 08:30:00

2,01/01/2020 09:30:00

];

 

The final table should look like:

CarStartTimeEndTimeLineNr. Passengers
101/01/2020 08:0001/01/2020 08:401001
101/01/2020 08:4001/01/2020 09:201002
101/01/2020 09:2001/01/2020 10:001000
201/01/2020 08:0001/01/2020 08:401012
201/01/2020 08:4001/01/2020 09:201010
201/01/2020 09:2001/01/2020 10:001011

 

Thanks in advance

Labels (2)
1 Solution

Accepted Solutions
Vegar
MVP
MVP

I was able to get this from the script in the bottom.

Vegar_0-1600696024115.png

 

 

Travels:
Load * inline
[
Car,StartTime,EndTime, Line
1,01/01/2020 08:00:00, 01/01/2020 08:40:00, 100
1,01/01/2020 08:40:00, 01/01/2020 09:20:00, 100
1,01/01/2020 09:20:00, 01/01/2020 10:00:00, 100
2,01/01/2020 08:00:00, 01/01/2020 08:40:00, 101
2,01/01/2020 08:40:00, 01/01/2020 09:20:00, 101
2,01/01/2020 09:20:00, 01/01/2020 10:00:00, 101
];

Passengers:
Load * inline
[
Car,Time
1,01/01/2020 08:10:00
1,01/01/2020 08:50:00
1,01/01/2020 09:10:00
2,01/01/2020 08:10:00
2,01/01/2020 08:30:00
2,01/01/2020 09:30:00
];
Left join
IntervalMatch (Time,Car)
LOAD StartTime, EndTime, Car
Resident Travels;


LEFT Join (Travels)
LOAD count(Car) as NoOfTravelers, StartTime,EndTime,Car
Resident Passengers
Group by StartTime,EndTime,Car
;
Drop table Passengers;

View solution in original post

2 Replies
Vegar
MVP
MVP

I was able to get this from the script in the bottom.

Vegar_0-1600696024115.png

 

 

Travels:
Load * inline
[
Car,StartTime,EndTime, Line
1,01/01/2020 08:00:00, 01/01/2020 08:40:00, 100
1,01/01/2020 08:40:00, 01/01/2020 09:20:00, 100
1,01/01/2020 09:20:00, 01/01/2020 10:00:00, 100
2,01/01/2020 08:00:00, 01/01/2020 08:40:00, 101
2,01/01/2020 08:40:00, 01/01/2020 09:20:00, 101
2,01/01/2020 09:20:00, 01/01/2020 10:00:00, 101
];

Passengers:
Load * inline
[
Car,Time
1,01/01/2020 08:10:00
1,01/01/2020 08:50:00
1,01/01/2020 09:10:00
2,01/01/2020 08:10:00
2,01/01/2020 08:30:00
2,01/01/2020 09:30:00
];
Left join
IntervalMatch (Time,Car)
LOAD StartTime, EndTime, Car
Resident Travels;


LEFT Join (Travels)
LOAD count(Car) as NoOfTravelers, StartTime,EndTime,Car
Resident Passengers
Group by StartTime,EndTime,Car
;
Drop table Passengers;

Vinerc
Contributor II
Contributor II
Author

Vegar, it worked great! Thank you very much!