Hi,
I have 3 column (Name,DOB,Age). age column have data. some rows is empty. if empty get DOB data.
Hi @MD_Farhan1
Can you try below linq:
dtOutput= (From row In dtInput.AsEnumerable()
Let age = If(String.IsNullOrEmpty(row.Field(Of String)("Age")), row.Field(Of DateTime)("DOB").ToString("yyyy-MM-dd"), row.Field(Of String)("Age"))
Select dtInput.Clone().Rows.Add(row.Field(Of String)("Name"), row.Field(Of DateTime)("DOB"), age)).CopyToDataTable
Hope it helps!!
Regards
Hi @MD_Farhan1
-
Read Range (Excel Application Scope)
Output: dtInput (DataTable) -
For Each Row (For Each Row activity)
Input: dtInput- If (If activity)
Condition: String.IsNullOrEmpty(row(“Age”).ToString())
- If (If activity)
-
Write Range (Excel Application Scope)
Input: dtInput
Hope it helps!!
Hi,
ForEach is Ver slow process because i have many rows.
Regards
Hi,
possible any other Method because Its Slove Processs.
Regards
DOB is date of Birth?
If yes, you would like to calculate Age based on DOB or replace Age cell with DOB value?
I don’t know how to solve it without for each.
I don’t have more ideas but you can try vb.net script:
for first option:
Dim currentDate As DateTime = DateTime.Now
For Each row As DataRow In dtData.Rows
If row("Age") Is Nothing OrElse String.IsNullOrWhiteSpace(row("Age").ToString()) Then
Dim dob As DateTime = DateTime.Parse(row("DOB").ToString())
Dim age As Integer = currentDate.Year - dob.Year
If dob > currentDate.AddYears(-age) Then age -= 1
row("Age") = age
End If
Next
for second option:
For Each row As DataRow In dtData.Rows
If IsDBNull(row("Age")) OrElse String.IsNullOrWhiteSpace(row("Age").ToString()) Then
row("Age") = row("DOB").ToString()
End If
Next
BlankProcess77 (2).zip (3.2 KB)
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.






