Check if multiple columns exist

Hi I am creating a datatable from excel before further data processing and manipulation. Before beginning with additional steps, I’d like to check that all necessary columns (10+) exist in the datatable otherwise I will get errors in following activities. (data may change sometimes). I have seen the following condition used, but is it possible to check for multiple?



You can check it by the following step.

First create string array variable which has each column name.

Then the following expression return boolean result.
arrColumnName.Where(function(x) dt.Columns.Contains(x)).Count=arrColumnName.length


1 Like

Hi - thank you! What type of activity should i use to return the boolean result?
Can you elaborate on the function and the value of x?


You can use it in If activity directly as the following image.


function(x) dt.Columns.Contains(x) is anonymous function.
x is sequentially set each array value.
Where method returns item if it contains x in your columns of dt.
As a result, if all columns which you expect exist, the result length equal strArrayColumn length.


Hi all - thanks for the help. To simplify I just used the following approach.

dt.Columns.Contains(“column2”) AND dt.Columns.Contains(“column1”) etc.

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