“I am able to get unique value for single column in Power Automate, how to approach if we have more people picker columns and we need unique values?”
When you send reminders or reports using Power Automate flow, it’s a good practice to send as few emails as possible. If a user should know about 5 SharePoint items, you don’t want to send him 5 emails. You want to include all of them in a single one. But what if there’s not only 1 people picker column? Would you repeat the same process for each column separately? Send one email per column? Or would it be better to include all their items in a single email?
Get the unique values across the columns
In the original article you had only 1 people picker column. You extracted all the email addresses using the ‘Select’ action, and searched for the unique values using the union(…) expression.
Note: make sure that you switch to the ‘Text mode’ in the ‘Select’ action as that’s a very common mistake!
If you’ve got more than 1 people picker column, you’ll need the ‘Select’ action for each of them. For example, to get unique emails from Approver, Created By and Modified By columns.
You’ll have 3 outputs from the ‘Select’ actions, that’s 3 arrays with email addresses.
Since these are arrays, you can combine them together AND filter unique values using the union(…) expression. If you have just a single array, you use the same array twice to get the unique values. But this time you’ve got more arrays so you can use all of them – there’s no need to repeat.
union(body('Select'),body('Select_2'),body('Select_3'))
The result will be a single array that’ll contain only the unique emails among all the columns.
Find the corresponding items
Now, when you’ve got all the unique emails, it’s time for the loop. Find the items for each of the unique addresses, one by one.
But again, this time you’re not looking in a single SP column. You’re looking in more of them, and as such the filter will be more complex. You’ll need a combined filter that’ll check if the email address is in the Approval, Created By, or Modified By column. Use an extra ‘Filter array’ action to help you build the filter.
Create the filters one by one and put them all inside @or(…) operator, e.g.
@or(equals(item()?['ApproverSingle/Email'], items('Apply_to_each')),equals(item()?['Author/Email'], items('Apply_to_each')),equals(item()?['Editor/Email'], items('Apply_to_each')))
You’ll get only the items for the currently processed user which you can put into HTML table and send in an email.
Summary
There’s a bit of a difference between a Power Automate flow processing unique users in a single people picker or more people picker columns, but the approach is still the same. Firstly, extract only the relevant property – the email addresses in this case. Since there’re more columns you’ll need more ‘Select’ actions. Secondly, take all the emails, merge them together and extract duplicate values. And thirdly, since the emails can be in more columns, you must check all the columns in the filter.
All that’s left is to send the filtered items to the users, one email for each of them.