Column Values or Empty

Hi Everyone,

  1. Am converting the below sheet as "Empty_DT with the below condition. but when there is data of the “Line Attachment” column no issues. but if no data is in the “Line Attachment” column getting an error.

  1. After that making filter of “Line Attachment” into a separate sheet with the same Data table with the below condition.
    Need the condition of IF activity to find the “Line Attachment” column has data or is empty. the below snap for your reference.

In advance thank you for your support

@jaffer_sadiq its better to check if the row count is greater than 0, to do this put this given linq in if condition
(From x In datatabledt.AsEnumerable
Where Not String.IsNullOrEmpty(Convert.ToString(x(“Line Attachment”)))
Select x).Count>0
If the count greater than 0 than use your query it won’t throw the error

1 Like

Hi @jaffer_sadiq ,

If you want to only retain headers, then you can simply clone the DataTable and write that back to excel using Write Range Activity

Empty_DT.Clone()

If you want to validate whether the filters you are applying return any results, I would recommend assigning the values to a List of DataRows and check its count before assigning it to a DataTable →

Empty_DT.AsEnumerable().Where(Function(w) IsNothing(w("Line Attachement")) OrElse String.IsNullOrEmpty(w("Line Attachement").ToString)).ToList()

If the count is greater that zero, then assign it to a DataTable.

Empty_DT.AsEnumerable().Where(Function(w) IsNothing(w("Line Attachement")) OrElse String.IsNullOrEmpty(w("Line Attachement").ToString)).CopyToDataTable()

Kind Regards,
Ashwin A.K

1 Like

Empty_DT.xlsx (495.5 KB)

Hi Sanjit,

Thank you so much.

Once update the Assign activity throwing error, Please find the attached error snap file.

Hi Ashwin,

Thank you so much.

Attached are issues facing while updationg.

Blanket Order Test2 - Copy.xlsx (255.1 KB)

Hi @jaffer_sadiq ,

Is this the expected output?
image

If so, then here are the operations which were performed →

This code removes those rows which contain no data(only the S.No is present, btw if you want to retain them then comment out this part)

dt_sampleData.AsEnumerable().TakeWhile(Function(tw) Not(IsNothing(tw("Item Number")) OrElse String.IsNullOrEmpty(tw("Item Number").ToString))).CopyToDataTable()

This is the snippet which performs the check before assigning it to a DataTable →

dt_sampleData.AsEnumerable().Where(Function(w) IsNothing(w("Line Attachement")) OrElse String.IsNullOrEmpty(w("Line Attachement").ToString)).ToList()

And here is the updated workflow →

BlanketOrder.xaml (6.9 KB)

Kind Regards,
Ashwin A.K