Help me to create linq for following scenario

In this datatable whenever I have column1 value “4567” and column 2 value “1001” then column 3 it makes “failed” and in column 5 it make “failed adjustment”
Screenshot 2024-02-07 173827

@Swarit_Goyal

Can you elaborate a little on the ask

a sample output would help and instead of screenshot try uploading a file

cheers

@Swarit_Goyal

Please Upload the output file also

Hi @Swarit_Goyal
→ Read Range Workbook
Output-> dtInput
→ You can use the beow syntax in assign:

outputDT= (From row In dtInput.AsEnumerable()
                      Let col1 = row("Column1").ToString()
                      Let col2 = row("Column2").ToString()
                      Let col3 = If(col1 = "4567" And col2 = "1001", "failed", row("Column3").ToString())
                      Let col5 = If(col1 = "4567" And col2 = "1001", "failed adjustment", row("Column5").ToString())
                      Select dtInput.Clone().Rows.Add(col1, col2, col3, row("Column4"), col5)).CopyToDataTable()

outputDT is of DataType System.Data.DataTable

→ Write Range Workbook → outputDT
image

Hope it helps!!

hey @Swarit_Goyal
Use for each activity:

-> if `CurrentRow("Column1").ToString = "4567" AndAlso CurrentRow("Column2").ToString = "1001"`
Then
To: `CurrentRow("Column3")`
Value: `"failed"`
To: `CurrentRow("Column5")`
Value: `"failed adjustment"`

Along with then:

sounds like a column values update on a subset of rows.

Have a look here:

and have an overview on the different options for it.

Here is also discussed the

  • LINQ datatable reconstruction approach
  • the recommendation to work on filtered subset

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