I made an example that is a little different than your original flow. The main this is that I have moved the date filtering directly into the the Get Items in the Filter Query field. This will filter on the column by dates that are less than or equal to today's date plus 30. This is pretty much the same as your original Filter Query 2, except it is in the Get Items and Filter Query format.
The second difference is using an Array Variable to hold the email addresses. It does the same thing you did with combining using Union() expression, but it does it in the same variable which is then used as the source for Apply to Each 2.
So basically the flow is:
- Get Items (filtered by only the relevant dates)
- Initialize an Array Variable
- Apply to Each value from Get Items
- Append the Email value to the Array Variable
- Union() the Array Variable to remove duplicates
- Reset the Array Variable to the previous Union() so it now only holds unique emails.
- Apply to Each 2 - using the Array Variable as the source
- Filter Array the Get Items so that the Email value is equal to the current Array value
- Select the Filter Array and put the values into rows
- Create HTML Table using the Select output
- Send an Email using the HTML Table in the body
Here is an outline example flow:
Example Flow Outline
Here are the individual steps for the flow:
FlowDetail1
FlowDetail2
FlowDetail3
There are some steps where you will use different column titles from your SharePoint list. Like in the filter query, you need to use the internal sharepoint column name. My column was "BatteryExpirationDate" but your column will probably be "Battery_x0020_Expiration_x0020_D" so you will need to use that.
The same goes for in the Select action and the item()?['ColumnName'] for whatever data you want to include.
In my select action I used item()?['BatteryExpirationDate'] but you will probably use item()?['Battery_x0020_Expiration_x0020_D'] for the values.
Hope this helps!