Multiply two columns using Linq Query

Hi Everyone,

I want to multiply two columns in datatable using linq query (both columns are of type Double)

@ppr @PrankurJoshi @Palaniyappan @NIVED_NAMBIAR

1 Like

Hi @amalmarella

You can invoke a code like this

 var_DT.AsEnumerable().ToList().ForEach(r=> r.SetField("yourColumnName",r.Field<Double>("FirstColumn")*r.Field<Double>("SecondColumn")));

Thanks,
Prankur

1 Like

If your xaml is in C# then only use the above code.

1 Like


getting below error

var_DT.AsEnumerable().ToList().ForEach(Function (r)
r.SetField(“yourColumnName”,r.Field(“FirstColumn”)*r.Field(“SecondColumn”)))

Use this one

4 Likes

@amalmarella he is correct its a C# code. Thanks @Divyanshu_Divyanshu

1 Like

Hi @amalmarella

You can try this way and get the product of the 2 columns in a array too

data_arr= dt1.Select(Function(row) (CDbl(row(column1))*CDbl(row(column2))).ToString).ToArray()

Try this way too

Regards

Nived N :robot:

Happy Automation

1 Like

Thanks Ankur & divaynshu it is working , Thanks nived for your response

2 Likes

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