Gey Data From another Column

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

  1. Read Range (Excel Application Scope)
    Output: dtInput (DataTable)

  2. For Each Row (For Each Row activity)
    Input: dtInput

    1. If (If activity)
      Condition: String.IsNullOrEmpty(row(“Age”).ToString())
  3. Write Range (Excel Application Scope)
    Input: dtInput

Hope it helps!!

Hey @MD_Farhan1
You can do it this way:

Workflow:
BlankProcess77.zip (3.2 KB)

Hi,
ForEach is Ver slow process because i have many rows.

Regards

Hi,
possible any other Method because Its Slove Processs.

Regards

Hi @MD_Farhan1

Can you try the below way

Input:

image

Output:

image

Cheers!!

@MD_Farhan1

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.