Skip to main content
Community site session details

Community site session details

Session Id : 6JhnfqricaNMUuENYx2jkS
Power Apps - Building Power Apps
Answered

Setting DefaultSelectedItems from comma delimited string

Like (0) ShareShare
ReportReport
Posted on 19 Nov 2020 14:27:21 by 12

Screen 1;

In combo box 1 I have Items = ["Apple", "Orange", "Pear", "Banana"]

OnChange = UpdateContext({SelectedFruit: ComboBox1.SelectedItems})

 

Selected values need to saved as comma separated text string:

button.OnChange = UpdateContext({Fruits:Concat(SelectedFruit,Value&",")})

 

Fruits are then saved to a SPO text column

 

Screen 2:

I have another combo box and a button 

 

Combo box 2.Items = ["Apple", "Orange", "Pear", "Banana"]

 

I retrieve the value from the SPO column,

 

Retrieved value = "Pear,Banana,"

 

but first need to split it to convert to array

DefaultSelectedItems = ForAll(Split(Fruits,","),{Fruit:Result});

 

However, no values display. 

 

Thanks in advance

 

 

 

 

  • SP247 Profile Picture
    4 on 26 Feb 2024 at 09:50:31
    Re: Setting DefaultSelectedItems from comma delimited string

    Hello @RandyHayes,

    My combo box values are from another SharePoint list column of single line text type, whereas the selected option need to be saved to another SharePoint list's column of type as single text. Saving is working well also the retrieval, but the values are not sync to the options in the combo box.

    Thanks & Best Regards,

    Santosh

  • RandyHayes Profile Picture
    76,287 Super User 2024 Season 1 on 19 Nov 2020 at 18:43:28
    Re: Setting DefaultSelectedItems from comma delimited string

    @donavanmarais 

    Yeah, I used to trim the text, but found it much easier to just filter the blanks out like in the formula.

    Glad it is moving forward for you now...

  • donavanmarais Profile Picture
    12 on 19 Nov 2020 at 16:37:52
    Re: Setting DefaultSelectedItems from comma delimited string

    That was exactly it. My bad. I totally neglected to trim that last comma.

  • Verified answer
    RandyHayes Profile Picture
    76,287 Super User 2024 Season 1 on 19 Nov 2020 at 16:36:20
    Re: Setting DefaultSelectedItems from comma delimited string

    @donavanmarais 

    I see you have a trailing comma on your values...didn't notice it before.  For that, change formula to the following:

    RenameColumns(Filter(Split(Fruits,","), !IsBlank(Result)), "Result", "Value")

  • donavanmarais Profile Picture
    12 on 19 Nov 2020 at 16:33:43
    Re: Setting DefaultSelectedItems from comma delimited string

    Thanks for your response @RandyHayes 

    Unfortunately, that didn't work for me. Seems straightforward enough, however, the "Fruits" variable still display as a test string.

     

    combobox.png

     

    variable.png

  • RandyHayes Profile Picture
    76,287 Super User 2024 Season 1 on 19 Nov 2020 at 15:32:46
    Re: Setting DefaultSelectedItems from comma delimited string

    @donavanmarais 

    Consider the following change to your DefaultSelectedItem property:

       RenameColumns(Split(Fruits,","), "Result", "Value")

     

    Your Items property specifies a single column table with a column called Value:

       ["Apple", "Orange", "Pear", "Banana"] is turned into the following:

       [{Value:"Apple"}, {Value:"Orange"},{Value:"Pear"},{Value:"Banana"}]

     

    So to get default selected items to match, you need to match the column names.  So the above formula will rename the "Result" column to "Value" - which will match.

     

    I hope this is helpful for you.

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

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410 Super User 2025 Season 2

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 2

Loading complete