Not inserting column data if it met certain criteria


I was trying to create an excel file based on my query from the database and it was working. There are some enhancement I want to make for example if the sum of invoice amount is 0 in the query, it won’t enter those column in the excel sheet. Is there any possible way to do this?

Hey @Seungwan :wave:

Why don’t you use an if condition to check the sum of invoice amount?

Hi @monsieurrahul,

Thanks for the reply. I’m checking the amount from the query, it’s just that I’m not sure how to perform this. Like when writing to excel do I check with the generated datatable column name if it equals to “column name” for example, then it won’t write it or delete it after the column has been generated?

You can get the sum of a particular column using the compute method:

YourDT.Compute(“SUM(ColName)”, “”).ToString

You can use this expression inside an if condition to check if it is equal to 0 and perform the write actions accordingly.

Hi @monsieurrahul,

Seems like a solution for me!
Really appreciate the help.

1 Like

Glad I could be of help! Cheers!

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