Subscribe Bookmark RSS Feed

Problem of create column

Highlighted
blue1994

Contributor

Joined:

Feb 27, 2017

Hi, all
I had face a very simple problem which is create the column.
When I single run the below code, it come out this error in the log

Try(dt_firstseq_summary << Delete Column( "Percent" ) );
dt_firstseq_summary << New Column( "Percent",
	Numeric,
	Continuous,
	Format( "Best", 8 ),
	Formula( :Name("Total_Tested") / Col Sum(:Total_Tested) )
);
dt_firstseq_summary :name( "Percent" ) << Delete formula;

Error:

Send Expects Scriptable Object in access or evaluation of 'Send' , dt_firstseq_summary << /*###*/New Column( "Percent",
Numeric,
Continuous,
Format( "Best", 8 ),
Formula( :Total_Tested / Col Sum( :Total_Tested ) )
) /*###*/

 

In the following script, error marked by /*###*/
Try( dt_firstseq_summary << Delete Column( "Percent" ) );
dt_firstseq_summary << /*###*/New Column( "Percent",
Numeric,
Continuous,
Format( "Best", 8 ),
Formula( :Total_Tested / Col Sum( :Total_Tested ) )
) /*###*/;
dt_firstseq_summary:Percent << Delete formula;

 

But when I run my whole program, it able to create the column in data table, but the percent column cannot calculate the value.See photo below:

photo01.png

Error:

Column Percent Formula Interrupted
Name Unresolved: Total_Tested 1 times At rows: 2 Operation: Total_Tested, :Total_Tested/*###*/
Formula evaluation errors have been ignored

May I know how to fix it?

Any answer is appreciate.

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
markbailey

Staff

Joined:

Jun 23, 2011

Solution

Save the data table reference that is returned from the join operation. Then use it to send messages to create the new column  that you want. Like this:

dt_joined = dt_firstseq_summary << Join(
	With(dt_final_summary),
	Select( :S_B_Name, :N Rows, :Name( "Percent" ) ),
	SelectWith( :S_B_Name, :N Rows, :Name( "Percent" ) ),
	By Matching Columns( :S_B_Name = :S_B_Name ),
	Preserve Main Table Order();
	Output Table Name("Combined Table");
);
dt_joined << New Column( ... ):
Learn it once, use it forever!
4 REPLIES
txnelson

Super User

Joined:

Jun 22, 2012

Is it possible that your summary table is still linked to the raw data table and that is causing your issue?

I tried your code with a mocked up version of your data table and had no issue with the code.

Jim
blue1994

Contributor

Joined:

Feb 27, 2017

Hi, Jim
Yes, the summary table will linked with raw data table.

I will try again.

Thanks for help.

blue1994

Contributor

Joined:

Feb 27, 2017

Hi, everyone
I now able to join the 2 data table together into one data table.(combined data table)
But now my problem is how to create another new column into the combined data table? 

This is my join script to join 2 data table together:

dt_firstseq_summary << Join(
	With(dt_final_summary),
	Select( :S_B_Name, :N Rows, :Name( "Percent" ) ),
	SelectWith( :S_B_Name, :N Rows, :Name( "Percent" ) ),
	By Matching Columns( :S_B_Name = :S_B_Name ),
	Preserve Main Table Order();
	Output Table Name("Combined Table");
);

Thanks.

 

markbailey

Staff

Joined:

Jun 23, 2011

Solution

Save the data table reference that is returned from the join operation. Then use it to send messages to create the new column  that you want. Like this:

dt_joined = dt_firstseq_summary << Join(
	With(dt_final_summary),
	Select( :S_B_Name, :N Rows, :Name( "Percent" ) ),
	SelectWith( :S_B_Name, :N Rows, :Name( "Percent" ) ),
	By Matching Columns( :S_B_Name = :S_B_Name ),
	Preserve Main Table Order();
	Output Table Name("Combined Table");
);
dt_joined << New Column( ... ):
Learn it once, use it forever!