Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Highlighted
alexandermllr
Contributor

Qlikview - Join 2 tables with more keys

Hello,

I have this table:

  

KeyTimePlace
101.01.2018 02:002464
101.01.2018 05:064657
102.01.2018 01:453578
102.01.2018 16:128767
102.01.2018 19:001245

and i need to join this table to the first one:

KeyPlace fromPlace toNew Field
12464357843113
18767124544121

So I have the Key field and the place as a "Key" + the time for the sorting.

This should be the result:

  

KeyTimePlaceNew field
101.01.2018 02:00246443113
101.01.2018 05:06465743113
102.01.2018 01:45357843113
102.01.2018 16:12876744121
102.01.2018 19:00124544121

I hope someone can help me!

Thank you

5 Replies

Re: Qlikview - Join 2 tables with more keys

alexandermllr
Contributor

Re: Qlikview - Join 2 tables with more keys

Thank you!

I tried it, but it's not working for my data because the fields "place from" and "place to" are not sorted.

I need to use the "Time" for matching it.

How is it possible?

marcelviegas
Contributor II

Re: Qlikview - Join 2 tables with more keys

attempts to concatenate the keys (compound key)


key1&'|'&key2

alexandermllr
Contributor

Re: Qlikview - Join 2 tables with more keys

That's not working with my data.

In my example the Place "4657" would have no new field then, because it's between...

Re: Qlikview - Join 2 tables with more keys

The idea of IntervalMatch() is exactly to simplify that exercise that anyway you have to do. If you have missing values (out of range, out of the interval) you should create such intervals in the datamodel, unless those values are really to be dropped.

In your example, you would need to create a new line for the interval from 3759 to 8766, in this case with the value of 43113. I think you have some code examples in the threads I mentioned but if you search the Qlik Community you will find a lot more examples covering other uses cases perhaps more similar to yours.