LinQ Query to Update new column by Splitting the value of existing

Hi All,

i have an invoice column where i have split with # and update it in invNum, InvNum_Amt Coulmn I have combine both Splited invoicenum and Amount, and amt column needs to be clone same as invoice Amount.

I need this to be done using LinQ query, please help me on this

@Ramesh_Kola1

Add columns before using and then you can use below in invoke code send dt as in/out argument

dt.AsEnumerable.ToList.ForEach(Sub(x) x("InvNum")=x("Invoice Number").ToString.Split("#"c)(0).Trim)
dt.AsEnumerable.ToList.ForEach(Sub(x) x("InvNum_Amt")=x("InvNum").ToString + x("Invoice Amount").ToString)

You can as well use excel formula and auto fill range

cheers

1 Like

Hi @Ramesh_Kola1

Please use the below code in invoke code

' Assuming dt is your DataTable
Dim dt As DataTable = YourDataTableVariable
 
' Using LINQ to update values
dt.AsEnumerable().ToList().ForEach(
    Sub(x)
        x("InvNum") = x("Invoice Number").ToString().Split("#"c)(0).Trim()
        x("InvNum_Amt") = $"{x("InvNum")}_{x("Invoice Amount")}"
    End Sub
)

Input:

Output:

Workflow:

Regards

Thanks it worked well!!

1 Like

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