Group a data table multiplying and adding

I need to make a function that adds in the new column “calculate” the formula:
Col1*(1+Col3)*(1+Col2)
Captura de tela 2022-09-21 154327

Hi @ilanaribeiro95 ,

kindly check below mentioned workflow

Main (2).xaml (12.0 KB)

image

Thanks,
RajKumar

1 Like

Thanks. But…
I wanted a function

@ilanaribeiro95

var_DT.AsEnumerable().ToList().ForEach(Function (r)
r.SetField(“yourColumnName”, r.Field(“Col1”)(1+r.Field("Col3”))(1+r.Field(“Col2”))))

I tried this:
dt.AsEnumerable().ToList().ForEach(Function (r)r.SetField(“calculo”,r.Field(“col1”)(1+r.Field(“col3”))(1+r.Field(“col2”))))

don’t worked :confused:

Hi,

If you need function in the datatable, the following might help you.

dt.Columns("calculate").Expression = "col1*(1+col3)*(1+col2)"

If you need excel formula like =A1*(1+C1)*(1+B1), can you share address of the table in the worksheet.

Regards,

![Captura de tela 2022-09-22 090018|329x64](upload://o82:confused: TiKUCOJkU9GBBNW59glOrI.png)
:confused:

can you share your flow?

Hi,

If your datacolumn is object type, the following might be better.

dt.Columns("calculate").Expression = "Convert(col1,'System.Double')*(1+Convert(col3,'System.Double'))*(1+Convert(col2,'System.Double'))"

Sample20220922-1.zip (2.8 KB)

Regards,

1 Like

it worked!!

:heart_eyes: :smiling_face_with_three_hearts: :star_struck:

Thank you!!!

1 Like

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