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

Looking to automate a process and coming at problem from two methods, looking for guidance:

Hi all, I'm running a script that takes a column from a data table and summarises it like so:

names default to here(1);
dt = Current Data Table();

fails = dt << Summary(Group( :Test_Name ),Freq( "None" ),Weight( "None" ),Output Table( "Tests that have Failed" ));

The general method in our process is to select a row in the table created:

OC200m_0-1677153355587.png

There can be any number of rows in this first summary table shown above so it needs to be implemented using a for loop to remain general. When doing manually, I select one of the rows in this summary column, return to the original table, right click "selected" in the bottom corner and then click "data view" like below

OC200m_0-1677161861389.png

 

then apply this script to it: 

 

names default to here(1);
dt = Current Data Table();

dt << text to columns( delimiter( ":" ), columns( :Test_Result ) );
dt << Summary(Group( :Test_Result 2 ),Freq( "None" ),Weight( "None" ),Output Table( "Patterns to Keep" ));

I have tried doing in another way:

 

I am trying to access each element in the test_name column of the summary table in a for loop, trying to select the elements equal to the test_name selected by the for loop in the original table and creating a subset table from that, then summarising that but the debugger isn't being verbose enough to see the issue:

names default to here(1);
dt = Current Data Table();
fails = dt << Summary(Group( :Test_Name ),Freq( "None" ),Weight( "None" ),Output Table( "Tests that have Failed" ));
testlist={};
For( i = 1, i <= Nrows(fails), i++, test=Column(fails,i);
tab= dt << select where(contains(:Test_Name,test));
For( i = 1, i <= Nrows(fails), i++,
		tab << Summary(Group( :Test_Result 2 ),Freq( "None" ),Weight( "None" ),Output Table( "Patterns to Keep" ));

	

 

Any guidance on either how to piece together my first attempt or to correct the issue with my second would be much appreciated!

1 REPLY 1
txnelson
Super User

Re: Looking to automate a process and coming at problem from two methods, looking for guidance:

I would solve the issue by just adding a BY() variable to your second Summary

tab << Summary(Group( :Test_Result 2 ),Freq( "None" ),Weight( "None" ),Output Table( "Patterns to Keep" ),
	by( :Test_Name )
);
Jim