web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Union issue with dupli...
Power Automate
Answered

Union issue with duplicates

(0) ShareShare
ReportReport
Posted on by 46
Hi All,
 
I have a Union Join expression set to remove duplicates from an Array Variable, however, the duplicate is still being returned and added to my string. Im sure Im missing something simple here but for he life of me I can see it. Can anyone help here please.



Categories:
I have the same question (0)
  • Suggested answer
    Fredrik_A Profile Picture
    3,570 Super User 2026 Season 1 on at
    Hello,
     
    I believe the issue is that one of the items is a number, and the other with the same value, is a string.
     
    If my response solved your issue, please mark it as ✅ Accepted Answer and give it a like.
  • Suggested answer
    chiaraalina Profile Picture
    1,860 Super User 2026 Season 1 on at

    Hi

    union() only removes items that are exactly equal (same value and same type). You are mixing a number (120990000) and a single string ("120990000,120990001").

     

    So nothing is a true duplicate and both survive, then join() just prints them all.

     

    Make sure you pass arrays of the same type (all numbers, or all strings) to union().

     



     

  • Adam_Travers Profile Picture
    46 on at
    Many thanks for the response. I have updated the Flow to ensure both are strings but its still returning the duplicate

  • Suggested answer
    Tomac Profile Picture
    4,048 Moderator on at
     
    As @StretchFredrik said, the problem is that your array has one numeric value and one string. Instead of a simple union() function, you'll need to do something much fancier:
    union(split(replace(replace(replace(string(variables('array')),'"',''),'[',''),']',''),','),split(replace(replace(replace(string(variables('array')),'"',''),'[',''),']',''),','))
    I'm using an array variable named "array" in my example expression, so you'll need to change that reference to your input array.
     
    Here it is again as a multiline snippet:
    union(
    	split(
    		replace(
    			replace(
    				replace(
    					string(
    						variables('array')
    					),
    					'"',
    					''
    				),
    				'[',
    				''
    			),
    			']',
    			''
    		),
    		','
    	),
    	split(
    		replace(
    			replace(
    				replace(
    					string(
    						variables('array')
    					),
    					'"',
    					''
    				),
    				'[',
    				''
    			),
    			']',
    			''
    		),
    		','
    	)
    )
    Let's break it down. First, we need to convert the whole array to a string, then we have to remove (via the replace() function) the extra characters that the old array left behind. Then we split it back into an array of 3 string values, and use union() to remove duplicates from itself. If you need these to be numeric values, wrap the reference to them in the int() function when you go to use them.
     
    Here's the output of my sample run:
     
  • Verified answer
    Chriddle Profile Picture
    8,672 Super User 2026 Season 1 on at
    Just that?
     
    join(
        union(
            split(string(outputs('Compose-Value1')), ','),
            split(string(outputs('Compose-Value2')), ',')
        ),
        ','
    )
  • Adam_Travers Profile Picture
    46 on at
    Many thanks all! I have managed to resolve it from all of your help. Superstars!!  
  • Tomac Profile Picture
    4,048 Moderator on at
    @Adam_Travers Glad to hear you got it working. Please remember to mark the comment(s) that helped you as the answer to help future users find a solution to this problem.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 589

#2
Valantis Profile Picture

Valantis 328

#3
David_MA Profile Picture

David_MA 284 Super User 2026 Season 1

Last 30 days Overall leaderboard