How to swap details

So i want to swap tone column of my datatable, i want to swap The gender column where i have male and female gender for now

Hey @Kira , can u share the how the output should be

1 Like


Hi @Kira

  1. Add a For Each Row activity to loop through each row in the DataTable.
  2. Inside the loop use an Assign activity to swap the values.
  • Assign
  • Assign
CurrentRow("gender")=`If(genderValue = "Male", "Female", "Male")
  1. Use Output Data Table to convert data table to string and print the string output in Message Box.

Find the below workflow file . Hope it meets your requirement.
Sequence3.xaml (11.7 KB)

Hope it helps!!

Hi @Kira

Use the “For Each Row” activity to loop through the datatable.

Inside the loop, use an “Assign” activity to swap the values in the “gender” column:

Assign: tempGender = row(“gender”).ToString()
Assign: row(“gender”) = If(tempGender = “male”, “female”, “male”)

After for each row in data table use write range work book to see the result.

You can use invoke code activity and then write the below code

row(“Gender”)= If((row(“Gender”).tostring = “Male”), “Female”,
If((row(“Gender”).tostring = “Female”), “Male”, “”))
End Sub)

And pass the datatable as an argument
Hope it helps you out

1 Like

Hey @Parvathy , thank you for the solution but my professor needs it in query

Hi @Kira

Use this syntax:

(From row In dtInput.AsEnumerable()
          Let genderValue = row("gender").ToString()
          Select dtInput.Clone().Rows.Add(If(genderValue = "Male", "Female", "Male"), row("otherColumn1"), row("otherColumn2"))

Hope it helps!!

1 Like

@Kira , did u try this

Thsi worked, Thanks for the solution

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