Hi Expert,
I have an excel file and i need to divide by 2 the columns of IGST_CGST in all data rows and the result will come to each data rows in the result column. How can achieve this by LINQ. (Attached input file)
Thanks in advance
Division.xlsx (9.0 KB)
Anil_G
(Anil Gorthi)
February 7, 2024, 5:03am
2
@Balachander_Pandian
Please try this in invoke code and send dt as in/out argument
Dt.AsEnumerable.ToList.ForEach(Sub(r) r("ColumnName") = (cdbl(r("ColumnName").ToString)/2).ToString)
Also if column type is double then you can use expression as well in assign
Dt.Columns("TargetColumnName").Expression = "[Gstcolumn]/2"
Cheers
1 Like
rlgandu
(Rajyalakshmi Gandu)
February 7, 2024, 5:04am
3
@Balachander_Pandian
(From row In Dt.AsEnumerable()
Let IGST_CGST = Convert.ToDouble(row("IGST_CGST"))
Select Dt.Clone().Rows.Add(row.ItemArray.Take(2).ToArray().Concat({IGST_CGST / 2}).ToArray())).CopyToDataTable()
1 Like
Parvathy
(PS Parvathy)
February 7, 2024, 5:19am
4
Hi @Balachander_Pandian
resultDataTable= dtInput.Clone()
resultDataTable= (From row In dtInput.AsEnumerable()
Let IGST_CGST = CDbl(row.Field(Of Double)("IGST_CGST"))
Let Result = IGST_CGST / 2
Select resultDataTable.Rows.Add(row.Field(Of Double)("Sno"), IGST_CGST.ToString(), Result)).CopyToDataTable()
resultDataTable is of DataType System.Data.DataTable
Hope it helps!
1 Like
naveen.s
(Naveen S)
February 7, 2024, 5:53am
5
You can try with this:
Output = Enumerable.Range(0, number1).Count() / number2
1 Like
system
(system)
Closed
February 10, 2024, 6:53am
7
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.