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

How to fill values in rows till the end of an item group?

Hello everyone,

How to fill the column Param3 so that we have ones from the matching position (coming from the comparison of column Param1 and Param2) till the end of each item group (see the picture bellow)?

table_final.JPG

What I have now are only values in Param3 based on matching of Param1 and Param2. For that I use this really simple code:

For( i = 1, i <= N Rows( dt ), i++, 
	If( dt:Param1[i] == dt:Param2[i], 
		dt:Param3[i] = 1;
	)
);

table_initial.JPG

How to fill the Param3 column for further rows as shown in the first picture? I would appreciate for any suggestions.

Thank you and best regards

 

1 ACCEPTED SOLUTION

Accepted Solutions
Georg
Level VII

Re: How to fill values in rows till the end of an item group?

Perhaps this will work:

 

Names Default To Here( 1 );

dt = New Table( "Test",
	Add Rows( 10 ),
	Compress File When Saved( 1 ),
	New Column( "item",
		Character,
		"Nominal",
		Set Values( {"item1", "item1", "item1", "item1", "item1", "item2", "item2", "item2", "item2", "item2"} )
	),
	New Column( "Param1", Character, "Nominal", Set Values( {"", "A", "", "", "", "", "", "B", "", ""} ) ),
	New Column( "Param2", Character, "Nominal", Set Values( {"A", "A", "A", "A", "A", "B", "B", "B", "B", "B"} ) ),
	New Column( "Param3", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [., ., ., ., ., ., ., ., ., .] ) )
);

Wait( 3 );

group = .;
For Each Row(
	If(
		dt:Param1 == dt:Param2,
			dt:Param3 = 1;
			group = dt:Param2;,
		dt:Param2 == group, dt:param3 = 1,
		.
	)
);
Georg

View solution in original post

2 REPLIES 2
Georg
Level VII

Re: How to fill values in rows till the end of an item group?

Perhaps this will work:

 

Names Default To Here( 1 );

dt = New Table( "Test",
	Add Rows( 10 ),
	Compress File When Saved( 1 ),
	New Column( "item",
		Character,
		"Nominal",
		Set Values( {"item1", "item1", "item1", "item1", "item1", "item2", "item2", "item2", "item2", "item2"} )
	),
	New Column( "Param1", Character, "Nominal", Set Values( {"", "A", "", "", "", "", "", "B", "", ""} ) ),
	New Column( "Param2", Character, "Nominal", Set Values( {"A", "A", "A", "A", "A", "B", "B", "B", "B", "B"} ) ),
	New Column( "Param3", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [., ., ., ., ., ., ., ., ., .] ) )
);

Wait( 3 );

group = .;
For Each Row(
	If(
		dt:Param1 == dt:Param2,
			dt:Param3 = 1;
			group = dt:Param2;,
		dt:Param2 == group, dt:param3 = 1,
		.
	)
);
Georg
lukasz
Level IV

Re: How to fill values in rows till the end of an item group?

Hi Georg,

thank you, it is working as desired

Best regards