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
 [Newbie] Sum between a column and a variable

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
fremebondo Posted - 09/28/2009 : 12:20:27 PM
Hi, I've a first (maybe) stupid question, but I've been wasting time on it for hours.

I need to calculate the sum (or other more complicate functions) between a column in a worksheet and a coefficient (for every row). I want to save the result in a second column..... but I must be able to change the coefficient and to recalculate (auto or manually) the result.
Using project variable from command line I cannot update the result.
Which is the correct way to do this?

In Excel is so simple... I write =(A1+$C$1) in B1, auto-compl. or copy/paste (A[1:100] is the column with datas, C1 is the variable).

Thank you all and sorry for my bad english!

Fremebondo

I'm using
Origin Pro 8
Operating System: Win XP/VISTA
6   L A T E S T    R E P L I E S    (Newest First)
fremebondo Posted - 09/30/2009 : 06:31:10 AM
Perfect! Thank you for your help!
Penn Posted - 09/30/2009 : 06:06:13 AM
Hi Fremebondo,

In the first method, the means stored in Book2 can't be recalculated. However, in the second one, data in Sheet2 of Book1 are linked to the report sheet, that means that the data in Sheet2 of Book1 are always the same as those in report sheet. So the means stored in Book2 can be recalculated automatically.

Penn
OriginLab Technical Services
fremebondo Posted - 09/30/2009 : 04:51:37 AM
Thanks!

Only a question... I don't see any LOCK symbol on the new sheet's colums. Is it linked (auto or manual) to tree's data?
Penn Posted - 09/30/2009 : 01:39:24 AM
Hi Fremebondo,

If you want to call values of report sheets in Set Column Values window, maybe there are some LabTalk scripts needed. You can write the LabTalk scripts in the Before Formula Scripts text field. These scripts will be executed before setting column values.

The results in report sheets are stored in tree nodes, so it is necessary to get the results to a tree variable (using the X-Function named getresults). Then put the values in the tree nodes to a dataset variable. The dataset variable is used to Set Column Values.

Suppose there are the descriptive statistics results for five columns in Book1. Now, the means for these five columns need to store in Book2.



The scripts are:
// get the results to a tree tt
getresults tr:=tt iw:=[book1]DescStatsOnCols1!;

dataset mean_result; // define a dataset mean_result
mean_result.SetSize(5); // set dataset's size, according to the result number

// define a temporary book and temporary column
newbook result:=newname$;
range tem_book=[newname$];
range tem_col=[newname$]sheet1!col(a);

// loop all means and store them in tem_col
for(ii=1;ii<=mean_result.GetSize();ii++)
{
	tem_col[$(ii)]=tt.Statistics.C$(ii).Mean;
}
mean_result=tem_col; // assign mean_result by tem_col
delete tem_book; // delete the temporary book

For more information about the X-Function getresults, please refer to the following web page:
http://www.originlab.com/www/helponline/Origin8/en/mergedProjects/X-Function/X-Function.htm#X-Function/Getresults.html


There is another easy way with only one LabTalk script, though there is a new worksheet created. Right-click on the corresponding tree node in the report sheet and select Create Copy As New Sheet. Then a new worksheet is created with the results in this tree node. The new worksheet is a common sheet, so it is much easier to get the results.



Penn
OriginLab Technical Services
fremebondo Posted - 09/29/2009 : 07:58:20 AM
Thank you, I've solved with your method.

My mistake was in referring to single data: I used a range var in the script, bounding with [1:1], but only one val was created. With col(A)[1] it works!

There is a way to call values of report sheets (for example, column's mean calculated with statistic analysis) in Set Column Value window?

I have to build a data column filled with means of columns in other sheets.

Thanks again!
Penn Posted - 09/29/2009 : 02:35:04 AM
Hi Fremebondo,

You can calculate the sum you said above using Set Column Values (Highlight a column and select Set Column Values from the right-clicked menu.).

Now, I suppose your data are in column A, coefficient in the first cell of column B and the result will be stored in column C.

Highlight column C and right-click it. Then select Set Column Values from the short-cut menu. In the pop-up dialog box, type ¡°col(a)+col(b)[1]¡± in the first text field and select ¡°Auto¡± in the Recalculate drop-down list. Click the OK button to finish setting values.



You can refer to the following web page for more information about Set Column Values.

http://www.originlab.com/www/helponline/Origin8/en/origin.htm#category/using_formulae_to_set_or_transform_worksheet_column_values.htm

Penn
OriginLab Technical Services

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