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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Setting DefaultSelecte...
Power Apps
Unanswered

Setting DefaultSelectedItems from comma delimited string

(0) ShareShare
ReportReport
Posted on 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

 

 

 

 

Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @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.

  • donavanmarais Profile Picture
    12 on at

    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

  • Verified answer
    RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @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 at

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

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @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...

  • SP247 Profile Picture
    4 on at

    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

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard