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
 Maximum
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

pandapo

9 Posts

Posted - 07/19/2011 :  07:44:02 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi!
I have two columns one with time and one with my values, I would calculate the maximum of the column with my values and have in output the maximum and the corresponding time. Someone knows how to do it?

Hideo Fujii

USA
1582 Posts

Posted - 07/19/2011 :  10:14:59 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi pandapo,

There may be a smarter way, but the following is one method: 

1) In Script window, type the following two commands (press ENTER at each command):
  range BB=2;
  sum(BB);
Here, "2" in the first line indicates the column number.

2)Choose "Worksheet: Worksheet Query" menu, select and move(=>) the 
all target columns to right panel (the 2nd column got the alias "B"), 
and enter the following condition:
  B=sum.max
and run it.

Hope this works for you.

--Hideo Fujii
OriginLab
Go to Top of Page

pandapo

9 Posts

Posted - 07/19/2011 :  10:35:14 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
and if I want to do it for a template file, with an unknown number of columns?
Go to Top of Page

Hideo Fujii

USA
1582 Posts

Posted - 07/19/2011 :  10:48:52 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

If you don't know the column number, you can use the column name 
instead of the column number in the "range" declaration such that:

  range BB=col(B);
  sum(BB); 

--Hideo Fujii
OriginLab

Edited by - Hideo Fujii on 07/19/2011 10:50:17 AM
Go to Top of Page

pandapo

9 Posts

Posted - 07/19/2011 :  11:11:53 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I cannot find this worksheet query :(
Go to Top of Page

pandapo

9 Posts

Posted - 07/19/2011 :  11:19:43 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I have Origin 8.1
Go to Top of Page

Hideo Fujii

USA
1582 Posts

Posted - 07/19/2011 :  11:25:04 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

quote:
Originally posted by pandapo

I cannot find this worksheet query :(



Before Origin 8.5, the menu was called "Extract Worksheet Data".
From next time when you post, as a general manner, please write your Origin version.

Thank you.

--Hideo Fujii
OriginLab
Go to Top of Page

pandapo

9 Posts

Posted - 07/19/2011 :  11:47:45 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
oh! you are right!

It seems to work just with the first column :(

so my first column is the time (T), the second is B, and then many C ( C1, C2...); I would search the maximum of each column and the corresponding time;
what the script does now, is to search the maximum of the column B, give the time corresponding of the maximum and then give me back also all the other columns' values at that time :(
Go to Top of Page

Hideo Fujii

USA
1582 Posts

Posted - 07/19/2011 :  2:50:01 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi pandapo, 

Well... because you said you have two columns, so that is what I 
intended. If you want to apply the same thing to bunch of columns 
repeatedly, you need to have some sort of automitization. 

For example, the following script applies "wextract" command (see 
"Help:X-Functions" help for details) to every column after the second 
column to the rest. You can copy-and-paste to the Script window, 
highlight all lines, then press ENTER key to run: 

%A=%H; //book name
%L=layer.name$; //sheet name
nc=wks.ncols; //colums
for(ii=2;ii<=nc;ii++) {
  range B=[%A]%L!col($(ii));
  sum(B);
  wextract iy:=[%A]%L!(1:end) settings.stAlias.Cols:=$(ii) settings.stAlias.AliasNames:=BB$(ii) settings.stCondition.Condition:="BB$(ii)=sum.max" settings.stMethod.Method:=1 settings.Cols:="0|$(ii-1)";
  wcol(2)[C]$=From Col$(ii);
};

Hope this works!

Edited by - Hideo Fujii on 07/19/2011 2:52:47 PM
Go to Top of Page

pandapo

9 Posts

Posted - 07/20/2011 :  04:50:41 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Hideo,
I did:
-open worksheet---> extract worksheet data ---->Scripts-->

%A=%H; //book1
%L=layer.name$; //myworksheet
nc=wks.ncols; //col(c)
for(ii=2;ii<=nc;ii++) {
range B=[%A]%L!col($(ii));
sum(B);
wextract iy:=[%A]%L!(1:end) settings.stAlias.Cols:=$(ii) settings.stAlias.AliasNames:=BB$(ii) settings.stCondition.Condition:="BB$(ii)=sum.max" settings.stMethod.Method:=1 settings.Cols:="0|$(ii-1)";
wcol(2)[C]$=From Col$(ii);
};


in the window Script before select data loop

Then in the 'if' window I wrote:
B=sum.max

I selelcted all the columns from left to right and then Apply.

It doesn't work :(
Go to Top of Page

Hideo Fujii

USA
1582 Posts

Posted - 07/20/2011 :  11:30:51 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

This script is a self-contained, and as I wrote, you need to copy-and-paste to the
Script window ("Window: Script Window" menu), highlight ALL lines, then press ENTER key to run.

--Hideo Fujii
OriginLab

Edited by - Hideo Fujii on 07/20/2011 11:31:45 AM
Go to Top of Page

pandapo

9 Posts

Posted - 07/20/2011 :  11:43:57 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
it gaves me back just the maximum value of the last column with the corresponding time :(
Go to Top of Page

Hideo Fujii

USA
1582 Posts

Posted - 07/20/2011 :  3:28:20 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Probably you have overlooked other worksheet tabs by not scrolling to left using the triangle buttons at the bottom of the workbook. Or, not?

--Hideo Fujii
OriginLab
Go to Top of Page

pandapo

9 Posts

Posted - 07/21/2011 :  04:21:26 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi!
now it gives me the the maximum and the corresponding time for each channel, but each channel is placed in another worksheet. I would like to have, if it is possible, all channels with maximum and corresponding time in one tab. Do you know if it is possible?

Go to Top of Page

pandapo

9 Posts

Posted - 07/21/2011 :  05:23:39 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
anyway.. it is fine in this way..thank you a lot! :)
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