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
 Apply formula to 400 columns in a book
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

james_last

1 Posts

Posted - 07/10/2016 :  2:11:40 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 9G
Operating System: Windows 7

Hello,

I played around with the calculate column values function and want to apply now my formula to every column, I have around 400 in one book, so manually this takes too much time. I saw the scripting window but I don't know how to apply a variable instead of a col number like in the column function. I want to apply the formula to every column and after this for every column I need a formula to find Min and Max value in the data and apply again a formula on the column with Min and Max as variable. I'm wondering if this makes it necessary to save Min/Max to a new cell or column in a calculated column or if there are funtions inside origin during recalculating column values to get min and max "on the fly" and then apply the formula with min and max as variables on it?

Thank you for your help

JacquelineHe

287 Posts

Posted - 07/11/2016 :  05:08:57 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

If I do not misunderstand your question, you want to calculate the Min and Max value for 400 columns and save the result to new columns, right?
You can try to use the loop script to calculate each column value.

This sample assumes the datasets are in the Book1. You can copy all the script to “Script Window” (Window: Script Window). Then highlight all the script and press “Enter” button.


//////////////////////////////////////////

newbook Book2;    //Create a new book to save the calculation result
col(1)[L]$ = "Min";    //Set column Longname
col(2)[L]$ = "Max";    //Set column Longname

win -a Book1;     //Active to Book1 with original datasets

// Following script is a loop script for 400 columns
for(ii=1; ii<=400; ii++)  
{
double aa;        //Declare a new variable of type double
aa=min(col($(ii)));      //get the minimum value from column(ii), and set value to “aa”
[book2]sheet1!Cell(ii,1)=aa;     //put “aa” value to Book2, sheet1, Column 1, row (ii)

double bb;      //Declare a new variable of type double
bb= max(col($(ii)));	    //get the maximum value from column(ii), and set value to “bb”
[book2]sheet1!Cell(ii,2)=bb;       //put “bb” value to Book2, sheet1, Column 2, row (ii)
}
win -a Book2;     //Active to Book2 

///////////////////////////////////////////////////////////



Please refer to the Labtalk help pages to know more details about the script.
http://www.originlab.com/doc/LabTalk/guide/Worksheet-Basic-Operation
http://www.originlab.com/doc/LabTalk/guide/Data-Types-and-vars
http://www.originlab.com/doc/LabTalk/ref/Min-func
http://www.originlab.com/doc/LabTalk/ref/Max-func
http://www.originlab.com/doc/LabTalk/ref/Cell-func

Thanks
OriginLab
Jacqueline
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