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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to use a self foreign keys but not in the load ?

Good day,

I would like to make a reference in my cross table, but on a field that have not the same name (a kind of self foreign key).

An exemple will be easier to explain.

Let's say I have the following table :

[CODE]

TblFriends:
LOAD * INLINE [
ID, Name, BestFriendID
1, Chandler, 3
2, Joey, 1
3, Ross, 1
4, Monica, 5
5, Rachel, 4
6, Phoebe
];

[/CODE]

And I want to make a chart that displays the best friends name :

error loading image

I can do this by adding

LEFT JOIN (TblFriends) LOAD
ID AS BestFriendID,
Name AS BestFriendName
RESIDENT TblFriends;

in my LOAD section, but I don't !

What formula can I use in my chart expression that says "SELECT Name FROM TblFriends WHERE ID = BestFriendID_in_my_current_dimension" ?

1 Solution

Accepted Solutions
Not applicable
Author

I reply to myself, it could help others...

FieldValue('Name', FieldIndex('ID', BestFriendID))


View solution in original post

3 Replies
Not applicable
Author

I reply to myself, it could help others...

FieldValue('Name', FieldIndex('ID', BestFriendID))


Not applicable
Author

table:
LOAD * INLINE [
ID, Name, BestFriendID
1, Chandler, 3
2, Joey, 1
3, Ross, 1
4, Monica, 5
5, Rachel, 4
6, Phoebe
];

Left Join

Load
ID as BestFriendID,
Name as BestFriendName
Resident table;


Above code is working

Not applicable
Author

Smile Smile Smile

I asked "how to do this NOTin the load" because I already know how to do it in the load.

The thing you replied is the "load solution" that was included in my file in the first message...

Stick out tongue