Table of contents
Unique and Distinct
Unique or Distinct, are synonyms essentially meaning only one of each.
But what does this mean for the Power Platform?
Say I have a list, or an array, of values:
[1, 2, 3, 3, 4, 5, 5, 5, 6, 7]
If I am in a Power Apps Canvas App, it’s easy-peasy to get the unique values of this list using the Power Fx function Distinct().
But what about when you’re in Power Automate? If you just look through the list of all the available function names for Collections, there is not a Distinct() function readily available…
But fear not, because the union() function will generate a distinct list of values! (You just have to trick it a little…π€«)
Basically, use your single array for both required arguments in the function. This works with numbers, text, and even records/objects (like items from a SharePoint List π€π‘).
Power Automate Exception
However, be aware that the union() function currently does NOT work as expected when using the new Power Automate Flow designer. In this case, it simply joins both lists of values together, meaning you now have a list with double the number of items as before! π¬
Switching to the Classic Flow designer does not easily fix this buggy behavior either. The bug persists even after you swap designers. This requires that you completely remove the action using the union() function, save, and refresh. Then you can add the action back in to use it as intended (for returning a distinct list of values).
I hope this information is helpful to someone else out there!