The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum
 Origin Forum
 VLOOKUP/HLOOKUP (excel) or JOIN LEFT (sql) analog
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

fut

2 Posts

Posted - 09/15/2011 :  03:37:00 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
How to create the third table using comparison of the same key field in two worksheets or workbooks? The first and second tables have the same key field. Result (3'rd) table should include key and date from the first and second table.

This is like Excel VLOOKUP/HLOOKUP function or SQL JOIN LEFT (union) query.

Origin Ver. and Service Release (Select Help-->About Origin): 8.5.1
Operating System: Win7

fut

2 Posts

Posted - 09/21/2011 :  11:25:40 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Ok. Let me clarify

I have two workbooks: book1 and book2. Book1 includes 118'000 lines, Book2 - 65'000 lines. These books have the same keys (Key column) and different data (Data1, Data2 in Book1 and Data10 in Book2).

I want to compare this books using the same keys and get third book which contain columns from Book1 and Book2. Something like this.

Go to Top of Page

Hideo Fujii

USA
1582 Posts

Posted - 09/21/2011 :  1:47:11 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi fut,

Origin currently doesn't have the JOIN operator like for the relational database.
For now, you need to make a script or OriginC code to do that.
For example, the following script may work for you, though this is quite inefficient and crude, and you may want to improve by adopting a better algorithm:
range Bk1C=[Book1]!col(C);
range Bk2B=[Book2]!col(B);
range Bk3A=[Book3]!col(A);
range Bk3B=[Book3]!col(B);
range Bk3C=[Book3]!col(C);

nr1=Book1!wks.maxRows;
keycol1=1; //col# in Book1
keycol2=1; //col# in Book2
jj=1;
for(ii=1; ii<=nr1; ii++) {
  window -a Book1;
  v1=wcol(keycol1)[ii];
  window -a Book2;
  flag=List(v1,wcol(keycol2));
  if(flag!=0) {
     Bk3A[jj]=v1;
     Bk3B[jj]=Bk1C[ii];
     Bk3C[jj]$=Bk2B[flag]$;
     jj++;
  }
}

If your column may have both numbers and text, or if you don't know that exclusively the column is either Text type or Numeric type, you can use the assignment like the following:

     if(Bk1C[jj]!=1/0) Bk3B[jj]=Bk1C[ii]; //numeric
     else Bk3B[jj]$=Bk1C[ii]$;  //characters

instead of Bk3B[jj]=Bk1C[ii];

--Hideo Fujii
OriginLab

Edited by - Hideo Fujii on 09/22/2011 3:51:48 PM
Go to Top of Page

Hideo Fujii

USA
1582 Posts

Posted - 04/11/2016 :  5:25:39 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Visitors to this thread:

Now Origin supports wjoinbycol x-function command to perform the Join operation from:
http://www.originlab.com/doc/X-Function/ref/wjoinbycol

For the above example, you can run the following command with the "unmatch" option:

wjoinbycol irng:=([Book1]Sheet1,[Book2]Sheet1) condition:="[Book1]Sheet1!A=[Book2]Sheet1!A" unmatch:=1 ow:=[<new>]<new>;

--Hideo Fujii
OriginLab

Edited by - Hideo Fujii on 04/11/2016 5:26:55 PM
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000