cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
MichaelO
Level II

Calculating Yield using Tabulate

Hi all,

 

I'm currently trying to write a script that will automatically calculate yields of tests across temperatures. I've replaced all "Pass" with 1's and "Fail" with a 0 throughout the table then calculated the sum. Below is my current Tabulate window and the code for this. My goal is to have a third column for each temperature with the yield which is  = ((Sum at Temp)/(N at Temp)) x 100. I'm having difficulties implementing this. I figure there is either a way to do this in Tabulate or to insert a Yield column after each "N" column and calculate the yield using the previous two columns in a formula, but am having trouble thinking how to do that in a way that accounts for a variable number of columns and test temperatures. Any help would be appreciated! Thanks in advance!

list = dt << Get Column Names( string );
Remove From(list, 1, testIndex);

yieldByTest = (dt << Tabulate(
		Add Table(
			Column Table(
				Grouping Columns(:tst_temp),
				Statistics(Sum, N, Mean)
			),
			Row Table(
				Analysis Columns(Eval(list))
			)
		),invisible
	)
) << Make Into data Table;
yieldByTest << Set Name("Yield by Test Across Temperature");

MichaelO_0-1658942858087.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
Georg
Level VII

Re: Calculating Yield using Tabulate

I think this can be done like this example below.

 

Georg_0-1659042600705.png

Names Default To Here( 1 );

// generate yield table
dt1 = New Table( "dt1", add rows( 9 ), New Column( "Process", "Character", values( Repeat( {"A", "B", "C"}, 3 ) ) ) );
dt2 = New Table( "dt2", add rows( 9 ), New Column( "Temperature", "Nominal", values( Repeat( {30, 40, 50}, 3 ) ) ) );
dty = dt1 << join( with( dt2 ), Cartesian Join );
For Each( {dt}, {dt1, dt2}, Close( dt, "NoSave" ) );
dty << set name( "yield" );
dty << New Column( "yield", "Numeric", "Continuous", set each value( Random Integer( 0, 1 ) ) );

// tabulate
dty << Tabulate(
	Show Control Panel( 0 ),
	Add Table(
		Column Table( Grouping Columns( :Temperature ), Statistics( Sum, N, Mean ), Analysis Columns( :yield ) ),
		Row Table( Grouping Columns( :Process ) )
	)
);
Georg

View solution in original post

3 REPLIES 3
jthi
Super User

Re: Calculating Yield using Tabulate

It might be easier to calculate yield by using Summary instead of tabulate:

jthi_1-1658944191872.png

If you want to use tabulate it might be easiest by using % Coluimn or % Row depending on how your data is formatted and still you might end up with a bit weird looking table:

jthi_0-1658944094800.png

 

-Jarmo
Georg
Level VII

Re: Calculating Yield using Tabulate

I think this can be done like this example below.

 

Georg_0-1659042600705.png

Names Default To Here( 1 );

// generate yield table
dt1 = New Table( "dt1", add rows( 9 ), New Column( "Process", "Character", values( Repeat( {"A", "B", "C"}, 3 ) ) ) );
dt2 = New Table( "dt2", add rows( 9 ), New Column( "Temperature", "Nominal", values( Repeat( {30, 40, 50}, 3 ) ) ) );
dty = dt1 << join( with( dt2 ), Cartesian Join );
For Each( {dt}, {dt1, dt2}, Close( dt, "NoSave" ) );
dty << set name( "yield" );
dty << New Column( "yield", "Numeric", "Continuous", set each value( Random Integer( 0, 1 ) ) );

// tabulate
dty << Tabulate(
	Show Control Panel( 0 ),
	Add Table(
		Column Table( Grouping Columns( :Temperature ), Statistics( Sum, N, Mean ), Analysis Columns( :yield ) ),
		Row Table( Grouping Columns( :Process ) )
	)
);
Georg
MichaelO
Level II

Re: Calculating Yield using Tabulate

Using the mean makes sense. I can't believe I didn't think of that!