Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
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
MVP
MVP

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
MVP
MVP

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
MVP
MVP

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