📧How to Remove Duplicate Email Addresses from a Set of Data Using Power Automate

Power Automate has a function that we can use to remove duplicate values and return a distinct or unique set of values: Union. For example, using the Union function [1] we can remove duplicate email addresses or names from a set or collection of data. [2]

The following Excel table contains multiple duplicate email addresses in the AssignedEmail column. We can write a flow to select just the AssignedEmail values and then use the Union function to remove duplicate email addresses:

Excel file with duplicate email addresses in the AssignedEmail column.

(1) We first use the Select action to select only the values in the AssignedEmail column. Note that the Select action needs to be in Text Mode as illustrated below:

Select action in Text Mode .

The runtime output of the Select action is shown below. The Select action will select all values from the AssignedEmail column:

The Select action will selects only the AssignedEmail column.

(2) We next use the Union function to remove duplicate email addresses. This is the expression used for the Union function:

The union function: union(body('Select'),body('Select'))
union(body('Select'), body('Select'))

This is the runtime output of the Union function. See how all the duplicate values have now been removed:

All the duplicate values have been removed using the Union function.

We are now left with an array of unique email addresses – exactly what we wanted!

We are left with an array of unique email addresses

Here is a demo flow using the unique set if email addresses:

Here is a demo flow using the unique set if email addresses:
The Send an Email action in the demo flow

Hope this helps.

Notes

  1. The Union Function: “Return a collection that has all the items from the specified collections. To appear in the result, an item can appear in any collection passed to this function. If one or more items have the same name, the last item with that name appears in the result.”
  2. Union of two sets: Sets cannot have duplicate elements, so the union of the sets {1, 2, 3} and {2, 3, 4} is {1, 2, 3, 4}. https://en.wikipedia.org/wiki/Union_(set_theory).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Website Built with WordPress.com.

Up ↑

%d bloggers like this: