Condition to check the column is blank or not in datatable

Hi All,

Sample data

consider this is a datatable (dt)
I want a condition/ Linq query to check if Rate Code column is blank/empty or not.
Please help!

Thanks in Advance

Hi @pradnyajadhav0712

first loop the data and make a check if String.IsNullorEmpty(CurrentRow(“RATE CODE”)).ToString Then String is Empty Else String is not empty. You can try this.

Hi @pradnyajadhav0712

Steps of process -
→ Use the read range workbook activity to read the excel and store in a datatable.
→ Take an assign activity and create a boolean variable and give the below linq expression.

- BoolFlag = (dt.Rows.Cast(Of DataRow)().All(Function(row) String.IsNullOrEmpty(row("RATE CODE").ToString())))

→ Take an If condition to check the BoolFlag value is True or false.

- Condition -> BoolFlag = True

→ In Then block give the activities if the column has no values.
→ In Else block give the activities if the column has values.

Check the below workflow for better understanding,

Input -

Output -

Hope it helps!!

Hey @pradnyajadhav0712,

Please refer the code below:

using System;
using System.Data;
using System.Linq;

class Program
static void Main()
bool isColumnEmpty = dt.AsEnumerable().All(row => string.IsNullOrEmpty(row.Field(“Rate Code”)));

    if (isColumnEmpty)
        Console.WriteLine("The column is empty.");
        Console.WriteLine("The column is not empty.");


Enclose the above code in an “Invoke Code” activity from the Properties panel and set the language property to C#.

Hope it helps!!

Hello All,

Thanks for the solution.

1 Like

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