Multiplication of 2 rows and storing in new column

When we multiply two columns by writing the formula in write cell,how to create a new data column and store the result of (multiplication of 2 rows) in the new column.
can you please share the code.

@anjani_priya

row(“Result”) = CDbl(row(“Column1”)) * CDbl(row(“Column2”))

Hello @anjani_priya, try something like this:

Excel Application Scope
Input: Path to Excel File

Read Range
Input: Excel sheet name, Range, Output DataTable: dtData

Assign
dtData.Columns.Add(“Result”, GetType(Double))

For Each Row in dtData
Assign
Double value1 = Convert.ToDouble(row(“Column1”)) ’ Replace “Column1” with your column name
Double value2 = Convert.ToDouble(row(“Column2”)) ’ Replace “Column2” with your column name
Double result = value1 * value2
Assign
row(“Result”) = result
End For Each

Write Range
Input: Excel sheet name, Range: “A1” (or the desired starting cell), DataTable: dtData

Cheers! :slight_smile:

Hey @anjani_priya ,
Please refer below file
Add_New_Column.zip (3.0 KB)

Hope it helps you out!

in write cell we cant create variable right.
i wrote the muliplication formula in write cell and i want to save that by creating new column called total

@anjani_priya

assign that value to a variable

total=CDbl(row(“Column1”)) * CDbl(row(“Column2”))

and pass that variable in the write cell activity

I took write cell and wrote the formula. How to create another column and store the values in new column.

@anjani_priya

Use add data column activity

To add a new column

Cheers

@anjani_priya

Two ways

  1. Write the formula in the excel cell directly using write formula activity and then use auto fill range to fill the formula to all the cells till the end…formula can be "=B2*C2"

  2. If when read into dattable if both the column type are same then just add a new column using add data column and then use assign with expression…which will apply for all rows dt.Columns("NewColumn").Expression = "[Column1Name]*[Column2Name]"

Cheers

task3.xaml (11.9 KB)
how can i create new column here and save the data in new column

Hi @anjani_priya

Please find the below xaml for your reference

BlankProcess8.zip (156.2 KB)

Hope this helps!!

I have done whole process but new column is not adding,even if I use addnew column.
task 3.1.xaml (14.2 KB)

In given code,new column is not adding.Only the new column is adding for the data which is >100.
task 3.1.xaml (14.2 KB)

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.