Replacing value in a columnI am trying to conditionally replace value in 2 columns in a table below. For example if fruit is mango replace color to black and quantity with 10.Is there an easy way to do this?
Fruit Color Quantity
Apple Red 1
Mango Yellow 2
Orange Orange 3
Banana Yellow 2
Grape Green 1
Re: Replacing value in a columnI was able to extend the for loop to replace values in the columns
Re: Replacing value in a columnThanks !This works.What if I dont know the value in columns.
If fruit is mango then I want to replace Quantity column value by color column value.
Re: Replacing value in a columnHere are 3 different ways to do this:
Names Default To Here( 1 );
dt = Current Data Table();
For Each Row(
If( :Fruit == "Mango",
:Color = "Black";
:Quantity = 10;
)
);
Names Default To Here( 1 );
dt = Current Data Table();
For( i = 1, i <= N Rows( dt ), i++,
If( :Fruit[i] == "Mango",
:Color[i] = "Black";
:Quantity[i] = 10;
)
);
Names Default To Here( 1 );
dt = Current Data Table();
Try( :Color[dt << get rows where( :Fruit == "Mango" )] = "Black" );
Try( :Quantity[dt << get rows where( :Fruit == "Mango" )] = 10 );