“I use Power Automate to send emails with an HTML table, but it keeps sending them even when the table is empty, how can I avoid that?”
If you use Power Automate to send email reports or reminders, it’s a nice touch to format the data in an HTML table. It’s so much easier to read the data if it’s in a table. But what if there’s no data to display in the table? The flow will send the table anyway, but this time it’ll include only the table header. Such email doesn’t have any information value, and probably won’t make any recipient happy. If such situation happens, you shouldn’t send that email at all.
Check if the table is empty
Before you send an email, you should check if the table is not empty. And while it might look as a simple check, I’ve seen many times the same problem. Users very often add a condition to evaluate if the output from ‘Create HTML table’ is empty.
It’s the right condition, but using wrong dynamic content. The output from the ‘Create HTML action’ will never be empty. It’ll always contain the header, even if there’s no data to add.
That’s why you must go one step back. Back to the action that can return an empty value: the input of the ‘Create HTML table’. Check if it’s empty, and send the email only if it is not, e.g.
empty(outputs('Get_items')?['body/value']) <is not equal to> true
It’s always important to use the right dynamic content in the right situation. If you want to check if an HTML table is empty, you must check the output from the right Power Automate action. And it’s quite easy to identify which one it is, just check the flow run history. You’ll see that the ‘Create HTML table’ contains the table header, while the ‘Get items’ returns  (= an empty array). That’s the action to check.