cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
mquyen
Level I

How to multiply all elements in a list

I am trying to figure out how to multiply the unreliability of all the sub-components per year. 

 

mquyen_1-1691799397165.png

I was thinking of creating an array for each year and use "Product" function to multiply all of the element within the array. But I feel like it will be loop within loops. Is there any suggestion to achieve this task?

 

Thank you.

2 REPLIES 2
txnelson
Super User

Re: How to multiply all elements in a list

Try using this formula

If( Row() == 1,
	x = :Useful Life Unreliability Rollup per Subcomponent type
);
If( Lag( :year ) != :year,
	x = :Useful Life Unreliability Rollup per Subcomponent type,
	x = :Useful Life Unreliability Rollup per Subcomponent type * x
);
x;
Jim
ron_horne
Super User (Alumni)

Re: How to multiply all elements in a list

@mquyen ,
the question you are asking should have been very simple to answer if only the tables>> summary platform or the Analyse >> tabulate procedure would have "Product" as an option.

meanwhile the way i would do it is as follows:
first split the table by year and group by subcomponent. then product is available as an option in formula for a new column.

Names Default To Here( 1 );
dt1 = New Table( "original",
Add Rows( 16 ),
New Column( "Sub-Component",
Character,
"Nominal",
Set Values( {"a1", "a1", "a1", "a2", "a2", "a2", "a3", "a3", "a3", "a4", "a4", "a4", "dc1", "dc1", "dc1", "dc2"} )
),
New Column( "Year", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1] ) ),
New Column( "unreliability", Numeric, "Continuous", Format( "Best", 12 ), Formula( Random Normal() ^ 2 ) )
);
dt2 = dt1 << Split(
Split By( :Year ),
Split( :unreliability ),
Group( :"Sub-Component"n ),
Output Table( "splilt_table.jmp" ),
Sort by Column Property
);
// New formula column: 1*2*3
dt2 << New Formula Column( Operation( Category( "Combine" ), "Product" ), Columns( :"1"n, :"2"n, :"3"n ) );

if you run this once, next time you can do the same on your data either by script or by clicking from menus. both should be reasonably easy.
please let us know if it works for you.