For each Data Row break at certain row/value

Hi,
I have a read range activity read a column with a list of numbers and possible “#N/A”. Next I have a for each row that will cycle through each data row from the read range activity. Inside the for each loop, I want the loop to break if the current row is “#N/A” what expression do I use in the if statement condition?

Use this expression in if Statement: row(“ColumnName”).Tostring.equals(“#N/A”)

Hi @lakshman ,

I did the read range without a header, what should I put in “ColumnName”?

Then use column Index instead of ColumnName.

1 Like

Please use index of column. For example

row(0) - refers first column value

1 Like

Hi, it doesn’t seem to work. Current workflow looks like this:


Excel looks like this:
image
Based on this, UiPath should be displaying the message “good” 3 times before it breaks. Is there something I did wrong?

Hi @anon5199880,

As per your input, during the first 3 iterations, the condition must fails and ‘Else’ block will execute. On the third iteration, the condition satisfies and control exists the loop. If your execution doesn’t work like this, please use the condition as row(0).Tostring = "#N/A" and try again.

Warm regards,
Nimin

hi @nimin,
UiPath is still displaying the message past the 3rd iteration.

Hi @anon5199880,

Could you please share the error message or output panel screenshot?

Warm regards,
Nimin

Hi @nimin,
This is the 4th iteration where row should be #NA


image

HI @anon5199880,

Can you try the below condition in your If Condition

row(0).ToString.Contains("#N/A")

Let me know whether this condition grabs the value properly…

Hi @anon5199880

Just give a try with this condition once, row(0).ToString.Trim.Equals(“#N/A”)

Although, row(0).ToString.Contains(“#N/A”) should work as well…

Thanks

Hi @Lahiru.Fernando and @ronak_94 ,
Both methods doesn’t work

Hi

Can you share your excel so I can check it out here?

@Lahiru.Fernando This is the file
test.zip (7.7 KB)

Hi @anon5199880,

Please try by removing ‘#’ from your string in excel and condition.

Warm regards,
Nimin

@nimin , Ok the process works now. However, what do I do to detect “#N/A”? The actual excel file I am running contains #N/A that I need to check for and cannot change it.

Hi, in the datatable, it actually captures the #N/A as a numeric value which is :“-2146826246”

That is because, when getting data into a datatable, it converts all the data of that column to a specific type. In your case, its numeric because first rows contain numeric values.

So try out this condition… it will work
row(0).ToString.Equals("-2146826246")

2 Likes

@Lahiru.Fernando, Thanks it works now.

1 Like

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