Source contains no data rows

Sometimes my column will not have any data and then i need to do something otherwise i need to continue.

I have it like this:

Now it can handle when the rows are empty under “Reg. på plats” but if i get transaction that contains something under “Reg. på plats” i still end up in the “Else” part.

What am i doing wrong?

If you’re looking to go to Else only if the entire column is empty, use tmpDataTable.Select("[Reg. på plats] = " ").Length = tmpDataTable.Rows.Count.



Still the same problem

Is it intentional that you’re comparing [Reg. på plats] = " " and not [Reg. på plats] = ""?


If everything is empty in “B” it should do the else part otherwise the “then”.

Hi @atomic,

I can see the simple way to achieve is with Try-Catch
I’ll suggest you to use select statement assign —> DT1 = tempDataTable.Select(…).CopyToDataTable <— in Try section.

  1. after that you can have sequence of process of expecting data in it (In try section right after assign)
  2. create system.exeption in catch and put sequence of process of expecting no data in it. (In catch section)

By this bot will able to do further tasks in try itself (when DT have data in it) and handle the exception of having no data in DT with another further tasks in Catch section.

I dont really know, I dont know what it doesnt work when it looks like it should

I will try this, but i would like to get the above thing to work. Cant see why it is messing with me

When you use a, but there are no rows which conform to the formula, it will give you an error saying source contains no data rows.

In your example at the start, you have used the .select method to create a list of rows where Reg… is " ". if there are no rows which conform to this, it will break, not just return a zero.

A way to get around this is to use the filter datatable activity instead, which works in a similar way to the .select method, but will not error when zero is returned. if you do this before your ‘If’ statement, and in the ‘If’ condition have a simple dt.rows.count>0 you should be good to go :wink:


can we just regather the requirement: it should be detected if there is any row in the datatable that having no or empty value in column Reg…)

the true false is in this scope and not on row level. Is my understanding correct?

tmpDataTable.Select("[Reg. på plats] = ''").Length  > 0

So the code above does not look if the lenght(characters) of the row is greater than 0?

tmpDataTable.Select(“[Reg. på plats] = ‘’”). copytodatatable.rows.count> 0 in if conditions

Try this

not clear matching my question

But lets approach different.

String.IsNulOrWhitespace(YourString) is returning false in case of a value is present and value is not “” or " "

it can be used for a check for entire datatable with following statement:
tmpDataTable.AsEnumerable.Any(Function ( r ) Not String.IsNullOrWhitespace(r([Reg. på plats).toString.trim))

returns true = all values are not null, “” or " "

I suggest to play with this within the watch box


Hi there man!

This is based on the previous task you helped me with.

Sometimes there is no “ja” in the column “Reg. på plats”
Thats why im looking for a way to use the If statement to look at the datatable and if everything is empty under “Reg. på plats” it should assign 0 to countJA otherwise it should do the “Then” part.

I dont really know I how i should use the things you described.

Start debugging till the point that tmpData is existing
Open watch panel
Copy statement in to the watch expression:
tmpDataTable.AsEnumerable.Any(Function ( r ) Not String.IsNullOrWhitespace(r([Reg. på plats).toString.trim))

an inspect the result true or false

If the statement is working as expected jus copy it into the if statement, that you have shown in the post above. Change for the true case the assignment to tmpData.Rows.Count

I started the debugging and when I saw the tmpData I inserted tmpDataTable.AsEnumerable.Any(Function (r) Not String.IsNullOrWhitespace(r([Reg. på plats).toString.trim)) in the expression place.

ah bad typo
remove the [nearby r(

Think im doing something wrong.

tmpDataTable.AsEnumerable.Any(Function (r) Not String.IsNullOrWhitespace(([Reg. på plats).toString.trim))

Still “Cannot evaluate”

tmpDataTable.AsEnumerable.Any(Function ( r ) Not String.IsNullOrWhitespace(r(“Reg. på plats”).toString.trim))