Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to link two fields in same table to another?

Record:

DateFromToValue
1/1/20161212
1/2/20162312
1/3/20163413
1/4/20164514

User:

UserIdUserName
1Peter
2Mary
3Ken
4Sam
5Alice

How can I link field (From) and (To) to UserID?

Many Thanks!

1 Solution

Accepted Solutions
sunny_talwar

Is this what you are looking to get?

Capture.PNG

Used IntervalMatch as mentioned by ecolomer

Script

RecordTable:

LOAD

    "Date",

    "From",

    "To",

    Value

FROM [lib://Comm]

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

User:

LOAD

    "UserId",

    UserName

FROM [lib://Comm]

(html, codepage is 1252, embedded labels, table is @2);

IntervalMatch:

IntervalMatch(UserId)

LOAD From,

  To

Resident RecordTable;

View solution in original post

4 Replies
ecolomer
Master II
Master II

sunny_talwar

Is this what you are looking to get?

Capture.PNG

Used IntervalMatch as mentioned by ecolomer

Script

RecordTable:

LOAD

    "Date",

    "From",

    "To",

    Value

FROM [lib://Comm]

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

User:

LOAD

    "UserId",

    UserName

FROM [lib://Comm]

(html, codepage is 1252, embedded labels, table is @2);

IntervalMatch:

IntervalMatch(UserId)

LOAD From,

  To

Resident RecordTable;

Anonymous
Not applicable
Author

Synthetic Key is existed.

Can we avoid it or it must exist?

sunny_talwar

You can avoid the synthetic key by joining.


RecordTable:

LOAD

    "Date",

    "From",

    "To",

    Value

FROM [lib://Comm]

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

User:

LOAD

    "UserId",

    UserName

FROM [lib://Comm]

(html, codepage is 1252, embedded labels, table is @2);

Left Join (User)

IntervalMatch(UserId)

LOAD From,

  To

Resident RecordTable;


Left Join (User)

LOAD *

Resident RecordTable;


DROP Table RecordTable;

But HIC points out that it isn't bad to have a synthetic keyIntervalMatch

Capture.PNG