Skip to main content

Notifications

Community site session details

Community site session details

Session Id : KyWjdhO/UVpfzz+38Yqd4m
Power Apps - Building Power Apps
Answered

Remove duplicates from string

Like (0) ShareShare
ReportReport
Posted on 4 May 2024 17:41:14 by 28

Hi,

 

I hope someone may be able to help me. I get the feeling this one is quite simple for some reason I just cannot get my head around the logic and formulas. Maybe I am still mentally stuck in Excel mode.

 

Anyway, I have a long string which is delimited by commas. I need to split it out, remove duplicates and put it back as a string again.

 

Any ideas? It is case-sensitive, if that matters?

  • Scott_UK Profile Picture
    28 on 05 May 2024 at 11:05:26
    Re: Remove duplicates from string

     Yes it was that lol.. must have needed my morning coffee. Thanks both.

  • Gochix Profile Picture
    1,933 Super User 2025 Season 1 on 05 May 2024 at 11:02:07
    Re: Remove duplicates from string

    @Scott_UK ,
    You might have an error because the code that @BhargavPatel  provided is for textInput field, but you require the solution for the Text field?

    Then the code would be 

    Concat(Distinct(Trim(Split(Text.Text,",")),Value),Value,",")


    _____________________________________________________________________________________
    Please give a thumbs up if I resolved your issue! Please click Accept as Solution to close the topic!

  • Scott_UK Profile Picture
    28 on 05 May 2024 at 10:57:52
    Re: Remove duplicates from string

    No matter, was operator error lol.

     

    Thank you for the formula, that works perfect 🙂

  • Scott_UK Profile Picture
    28 on 05 May 2024 at 10:50:31
    Re: Remove duplicates from string

    Hi,

     

    Thanks for the steer 🙂

     

    However, I get an error 'there is an error in this forumula' but oddly it doesnt highlight in red or say what part is wrong. Any ideas?

  • Verified answer
    BhargavPatel Profile Picture
    628 Super User 2025 Season 1 on 04 May 2024 at 17:57:54
    Re: Remove duplicates from string

    @Scott_UK Try this:

     

    Concat(Distinct(Trim(Split(TextInputCanvas1.Value,",")),Value),Value,",")

     

     

    In my case, the input for TextInuptCanvas1.Value is:

    1,1,1,2,2,2,3,4,5,6,7,8,9,9,9,0,0,0,1,1,3,3,4,5,6,7,8,9,10,11,12,13,14,11,11,12,and,AND,aND,And, And,And

     

    And my output using the code I posted is:

    1,2,3,4,5,6,7,8,9,0,10,11,12,13,14,and,AND,aND,And



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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,745 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,091 Most Valuable Professional

Leaderboard