Apply condition in excel

Hi,

How to check the condition if particular column in excel is start with particular number then how to update the value in next column accordingly.
Suppose we have some data given as below:
image

And I want to add the condition here like if enrollment number is start with ‘1’ the need to update the status column as CONFIRM and if enrollment number is start with 2,then need to update the status column as NOT YET PROCESS and so on…

Thanks,
Riya

use read range to read the excel
use for each datarow to loop through the row
use if row(0).toString.StartsWith(“1”) then assign row(“Status”)=“CONFIRM”
else if row(0).toString.StartsWith(“2”) then assign row(“Status”)=“NOT YET PROCESS”

1 Like

Read the range with ReadRange activity to Data table.

Then in a for each loop you can use string.startswith(“1”) and after that write the new values back
Something like this:

Hello @Riya1 Here like this total how many conditions are there?
If conditions are many, suggesting to use switch case activity activity.

1)use for each row in datatable
2)you can get the first value of the number using row(0).ToString.substring(0,1)
3)pass this switch. So case you have to create as 1, 2, 3 etc.

And you can use the write range to update the value after the case.

@Riya1

Find the workflow->
Sequence.xaml (10.2 KB)

I hope it will help you.

@Lak_Ui
Can you please share a sample xaml?

Thanks,
Riya

@Vaibhav_Rajpoot_17
Can you pls share snapshot of it? i am getting below screen only:
image

@Rahul_Unnikrishnan ,

Can you pls share sample xaml?

Thanks,
Riya

Sequence (2).xaml (11.5 KB)
Please check if it works for you

1 Like

@Riya1

Perform these steps->

1->

Read your input Excel file.

image
2->
iterate the datable.
image

3->
use switch case and pass the vale in it.
image

I hope it will help you, let me know for any query.

Hi @Lak_Ui ,

I have to update a value in 4th column and have total 4 condition how can I achieve this?

Thanks,
Riya

All these 4 condition are based on startwith number or differnt conditions. instead of assigning the value in row(1) in the code i had shared you cn use row(3)

@Lak_Ui All conditions start with startwith number only.
Please share the sample xaml if possible.

Sequence (2).xaml (11.4 KB)
You can update this wf as per your conditions

hope it is working

@Lak_Ui
Value is not updating against column.

you can change the code accordingly based on the column position or column name
for eg id column name is Status
you can use CurrentRow(“Status”) or if it is at 4 th position you can use CurrentRow(3) ie. position-1

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