How to move to next row

Hello everyone ,

We are using for each row to enter the details.

So wherever the value in Amt field is 0 then it should skip that row and move to next row is there a way to acheive it

Example

Amt|Code
10 |ANX99
0 |NYN88
88|WXN

So the 0 row details should be skipped and moved to next row

Thanks in Advance:)

Hi @anmita ,

You can put an if activity inside the for each loop and check if the row value equals 0 and if true then put continue activity in then block which will continue to the next row and put the required activities in the else block.

Condition to be put in if:

CurrentRow("Amt").toString.trim.equals("0")

Regards,

Hi,
Use If activity.
If: CurrentRow(β€œAmt”).ToString.Trim.Equals(β€œ0”)
Do nothing
Then:
What you want to do.

I hope this helps.

Hi @anmita

A better way should be to filter your dt and remove all the rows that contains 0, once filtered you will loop just through the rows you want without making validations within the for each row, you can use the filter datatable activity or else this linq code

Example:

(From d In dtInput.AsEnumerable()
Where Not d("Amt").ToString().Trim().Equals("0")
Select r = d).CopyToDataTable()

Result
image

Regards!

Hello,
I think the best way to filter the dt is:

  1. Use Read Range activity to read the excel file with dt_Input as the output.
  2. Use assign activity:
    dt_New = If(dt_Input.AsEnumerable
    Where Not (d(β€œAmt”).ToString.Trim.Equals(β€œ0”)).Any,
    dt_Input.AsEnumerable Where Not (d(β€œAmt”).ToString.Trim.Equals(β€œ0”)).CopyToDataTable, dt_Input.Clone)
    NB: dt_New is of type datatable.
    Use it to collect output datatable that has filtered out Amt with 0.
    This works either there are rows where the column Amt have 0 as value or not.
  3. Write Range activity and pass dt_New as the datatable to write.

@anmita

Actually you can first filter out the amt column with zero and then take the data into for loop so that if condition can be avoided for each iteration

Cheers

Hello @anmita
You can achieve this by using the IF condition for each loop

Otherwise can use the Filter data table, and remove the row which contains β€œ0” in the Amt column, so you don’t have the β€œ0” in it.

@anmita

Once you read the excel and have the datatable variable

Then you can use Filter datatable as Amount = 0.00, choose remove

Now you can use For Each row to iterate

OR

If you need to do with as it is then you can use If Condition

Thanks,
Srini

Thanks Everyone for the detailed responses

2 Likes

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