Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

reg---Self join in a table

Hi all,

In a excel sheet i m having empid,empname,managerid.

empid is same as managerid.

empidnamemgid
1Alex3
2John1
3Ram1
4Sham2


here i want to display the names of manager.

If i click 1 in empid, i want to generate Ram as manager name....

If i click 2&3 in empid ,i want to display Alex as manager name....

if 4 in empid, i want to display Johnas manager name...

In the source file no manager name is given.

How to achieve this?

thanks in advance,

Bharathe

17 Replies
Not applicable
Author

Hi

try in your load script

YourTable:
Load * from selfjoin.xls (...)

this will give you a table in QlikView named "YourTable"

now add the join according to Johns example.

Regards

Jürg

anitamelbye
Creator
Creator

Hi John, or someone else 🙂

Maybe this is not the right place to ask this question, but it has something to do with left joins, so I give it a shoot 🙂

I have 3 tables in my report, and I only want the orders witch are listed in my first table. Therefor, I have a Left Join on my 2'nd table load, in order to keep out any orders that are not listed in table 1.

But what can I write in my 3 load, in order to only keep the orders from Table 1?

If I write Left join on Table 3, my raport gets messed up. And if I leave out the Left Join, I get all the extra orders from table 3 in addition..

I hope I have been able to make my challenge clear for you to understand.

Table 1Table 2Table 3Orders wanted in report
101010
111111
121212
13131313
1414
1515
16
17
18
19
2020
212121
222222


I appreciated any help I can get, and I am so thankful for anybody wanting to try to help me 🙂

*Newbee in love*

Not applicable
Author

Hi Juerg Maier JmiD GmbH Schweiz,

i write the code like this....





LEFT

LOAD

name as "Manager Name"

RESIDENT

biff, embedded labels, table is Sheet1$);

self.xls

(

empid as mgid, JOIN (self.xls)

(biff, embedded labels, table is Sheet1$);



Its showing error while reloading as

Table not found
LEFT JOIN (self.xls)
(biff, embedded labels, table is Sheet1$)

Table not found
LOAD
empid as mgid
,name as "Manager Name"
RESIDENT self.xls
(biff, embedded labels, table is Sheet1$)

what to do now????

bharathe



Not applicable
Author

hi all ....

please guide me in solving this problem...

thanks in advance

bharathe

johnw
Champion III
Champion III


Bharathe11dec wrote:please guide me in solving this problem...


I gave you half the script, Jürg gave you the other half, and he told you to put his half first, my half second. Doing exactly what he said, you'd get this:

YourTable:
Load * from selfjoin.xls (biff,embedded labels,table is sheet1$)
;
LEFT JOIN (YourTable)
LOAD
empid as mgid
,name as "Manager Name"
RESIDENT YourTable
;

And that should work. It may not be exactly what you want, though. Presumably, you've already written the script to load from selfjoin.xls. We're not telling you to change that script AT ALL. All we're telling you to do is add MY script after it, and replace "YourTable" with the name you gave your table (and not with selfjoin.xls, which is your data source, not the name of your table). If your table is named "Employees" for instance, replace "YourTable" with "Employees" in the two spots it appears in the sample script I gave you.

johnw
Champion III
Champion III


Anita Melbye wrote: I have 3 tables in my report, and I only want the orders witch are listed in my first table. Therefor, I have a Left Join on my 2'nd table load, in order to keep out any orders that are not listed in table 1.
But what can I write in my 3 load, in order to only keep the orders from Table 1?
If I write Left join on Table 3, my raport gets messed up. And if I leave out the Left Join, I get all the extra orders from table 3 in addition..




You may have to post some sample data, because based on my understanding of what you're saying you're doing, there should be no problem, and you should get the exact result you posted. It sounds like you're doing something like this:

Table:
LOAD
Order
,Something
FROM Table1
;
LEFT JOIN (Table)
LOAD
Order
,SomethingElse
FROM Table2
;
LEFT JOIN (Table)
LOAD
Order
,SomeOtherField
FROM Table3
;

When you do the third load, the only Orders in Table should be the Orders originally loaded from Table1. Therefore, the left join should only take those orders from Table3, just like it did with Table2.

Not applicable
Author

Hi

John: where did you find the ü on your keyboard?

Bharathe: try to put copied code into a section code /code both between square brackes []. Much nicer to read and looks professional Wink

Jürg

johnw
Champion III
Champion III


Juerg Maier JmiD GmbH Schweiz wrote:John: where did you find the ü on your keyboard?


It's alt-129, but honestly, I just cut and pasted from your signature. Smile