How To Selected Column Using Its Header Inside If Else Statement

Hello, everyone I kind new with UiPath. I got table like this below, I want to make a reminder for monthly payment by cheking the value inside the column “Actual” on current month and the last month, what I’ve done was got the current month and I want to use it compare through it. Please the guidance.

Hey @kristoff

There would be two ways that I’d approach this:

  1. Read the Excel sheet into a data table and apply a filter on the columns that you’re using as conditions for your reminder
  2. Also read the Excel sheet into a data table then use a for each row to iterate through the table and compare the value of each of the two columns.

Hope this helps!

Thanks for your solution, I just want to get myself clear on using the filter row column you mean right Ms. @Jacqui_M?

Indeed. What are the conditions that you would like to apply, or what is it that you’d like to filter on? What should the row (and columns) contain for a reminder to be sent every month?

I only want to keep po number, company, last month and current month (which had planning payment and actual payment). So kind like this which this based on if based on this month.
“PO Number, Company, July 2020, Actual July 2020, Aug 2020, Actual 2020”
If the the month changed, the columns also would change

1 Like

Thank you for your advice beforehand. It help me so much, I got a different approach while talking to you. The code like this

// get the total column in DataTable
repeatColumn = dtPO.Columns.Count //DataType int

// assign the counter in while
countColumn = 0 //the increment variable DataType int

while(countColumn<repeatColumn-1){

countColumn = countColumn+1 // DataType int

// get the header column
nameColumn = dtPO.Colomns(countColumn).ToString

if(nameColumn.Contains(currentMonth)){
for each row in dtPO{
// the code below still error due to null
// valueInside = cint(row(countColumn))

  	//WriteLine using just for check the value 
  	WriteLine("Nilai dalam for each row " + row(nameColumn).ToString)
  }

}else{
//using for debugging only
WriteLine(“not contains current month” + row(nameColumn).ToString)
}

}

My gratitude to you Ms @Jacqui_M

1 Like

I’m glad you found a solution!

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