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
 All Forums
 Origin Forum
 Origin Forum
 Apply formula to 400 columns in a book

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
james_last Posted - 07/10/2016 : 2:11:40 PM
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
1   L A T E S T    R E P L I E S    (Newest First)
JacquelineHe Posted - 07/11/2016 : 05:08:57 AM
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

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000