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

Community site session details

Session Id : /dsyXY8G3R+AblSijMOHKA
Power Apps - Building Power Apps
Answered

Power Apps Default Selected Items

Like (0) ShareShare
ReportReport
Posted on 21 Apr 2020 22:28:38 by

Hello,

 

I have a combo box in the gallery where the values are populated based on the selection of another gallery item. The source for combo box gallery and selection gallery are different.

 

I'm able to display expected values in the combo, however, when a new value is added and submitted into collection, all the previous values are getting disappeared and only the newly selected value is collected.

 

Please advise.

 

Thanks

  • WarrenBelz Profile Picture
    148,894 Most Valuable Professional on 22 Apr 2020 at 10:15:39
    Re: Power Apps Default Selected Items

    @Anonymous ,

    @v-bofeng-msft has done a fairly comprehensive summary of all this - not much use me repeating it.

    I will leave you in their hands.

  • Verified answer
    v-bofeng-msft Profile Picture
    on 22 Apr 2020 at 08:52:50
    Re: Power Apps Default Selected Items

    Hi @Anonymous :

    Do you want to add values instead of replacing the original values by selecting operations in a combo box?

    Could you tell me :

    • What are these two gallery’s items property?
    • What is the combo box’s items property?
    • What are your data sources? Collection? Or SharePoint?
    • How did you submit the data? What is the specific formula?

    I guess it may be the problem of the code you submitted the data, it overwrites the old value with the new value.

    Because the information I obtained is not enough, I will first provide a scheme for adding values ​​based on the original records for your reference:

    I assume the combo box allow multiple selections.

    Solution1:Target is stored as a string

    My data source: MyTest

     

    ClearCollect(
     MyTest,
     {
     Title: 1, 
     Combovalue: First( /* Combovalue is a field used to store the records selected by combobox */
     ComboBoxSample /* predefined collection*/
     
     ).Value1
     },
     {
     Title: 2,
     Combovalue: Last(
     ComboBoxSample
     
     ).Value
     }
    )

     

    Step1:Add a gallery

    Items: MyTest

    Step2:Add a Combo box(ComboBox1) control into this gallery

    Items: ComboBoxSample

    DefaultSelectedItems: First(ComboBoxSample)  /* Set default selected items*/

    Step3:Add a button control into this gallery

     

    Patch(
     MyTest,
     ThisItem,
     {
     Combovalue: Concatenate(
     Combovalue,
     ",",
     Concat(
     ComboBox1.SelectedItems,
     Value1 & ","
     )
     )
    }
    )

     

     
     

    Solution2:Targets are stored in tables

    My data source: MyTest

     

    ClearCollect(
     MyTest,
     {
     Title: 1, 
     Combovalue: FirstN( /* Combovalue is a field used to store the records selected by combobox */
     ComboBoxSample, /* predefined collection*/
     3
     )
     },
     {
     Title: 2,
     Combovalue: LastN(
     ComboBoxSample,
     1
     )
     }
    )

     

    Step1:Add a gallery

    Items: MyTest

    Step2:Add a Combo box(ComboBox1) control into this gallery

    Items: ComboBoxSample

    DefaultSelectedItems: First(ComboBoxSample)  /* Set default selected items*/

    Step3:Add a button control into this gallery

     

    Patch(
     MyTest,
     ThisItem,
     {
     Combovalue: Ungroup( /* Integrate the original value and the new value into a new table and assign it to Combovalue */
     Table(
     {MyTables: Combovalue},
     {MyTables: ComboBox1.SelectedItems}
     ),
     "MyTables"
     )
     }
    )

     

     

    Best Regards,

    Bof

  • Community Power Platform Member Profile Picture
    on 22 Apr 2020 at 08:51:36
    Re: Power Apps Default Selected Items

    Hi @WarrenBelz ,

     

    The issue with ProcessArea(Combo box) is during editing values. As there will be already few values selected when item is created, user can come back and should be able to edit those items, may be they can remove existing values or add values. 

     

    This combo box in the gallery is part of repeating tables which means it will have multiple rows and these are collected in a collection on saving individual rows. 

     

    ImpactedAudienceTypes is the SP list where the combo box values are retrieved from

     

     

  • WarrenBelz Profile Picture
    148,894 Most Valuable Professional on 22 Apr 2020 at 08:02:27
    Re: Power Apps Default Selected Items

    Thanks @Anonymous ,

    To summarise what you have sent - firstly you are making a Collection

    ClearCollect(
     colProcessArea, 
     Filter(
     ImpactedAudienceTypes,
     Title in Projects.Selected.Title1
     )
    )

    You would be better using = or StartsWith as In is not a Delegable Filter.

    ClearCollect(
     colProcessArea, 
     Filter(
     ImpactedAudienceTypes,
     Title = Projects.Selected.Title1
     )
    )

    Then a Combo Box Items (which I assume is multi-select)

    Filter(
     'Drop down fields'.'Process Area ', 
     !IsBlank('Process Area ')
    )

    clearing out the blank items

    Then DefaultSelectedItems of the Combo Box - (not sure how this is relevant if user is selecting)

    ForAll(
     Filter(
     colProcessArea,
     ID=ThisItem.ID
     ),
     ThisItem.ProcessArea
    )

    I am trying to link it all together - you have said 

    The values in the combo are separated by ","  

    When multiple values are selected, for ex: When a new value (Test1) is added in the combo, only the new value is being collected (,Test1,)

    The collection is addressing ImpactedAudienceTypes - how is this relevant to your question?

    There is a process required to collect all SelectedItems of a Combo Box involving the Concat() function.

    Once I understand what you are doing here, I can probably help you.

  • Community Power Platform Member Profile Picture
    on 22 Apr 2020 at 07:18:52
    Re: Power Apps Default Selected Items

    Hi @WarrenBelz ,

     

    Thanks for the reply.

     

    Gallery (On Select) : ClearCollect(colProcessArea, Filter(ImpactedAudienceTypes,Title in Projects.Selected.Title1))

     

    Combo box in another gallery (Item) : Filter('Drop down fields'.'Process Area ', !IsBlank('Process Area '))

    DefaultSelectedItems: ForAll(Filter(colProcessArea,ID=ThisItem.ID),ThisItem.ProcessArea)

     

    The values in the combo are separated by ","  

    When multiple values are selected, for ex: When a new value (Test1) is added in the combo, only the new value is being collected (,Test1,)

     

    Thanks

  • WarrenBelz Profile Picture
    148,894 Most Valuable Professional on 22 Apr 2020 at 00:58:14
    Re: Power Apps Default Selected Items

    Hi @Anonymous ,

    Can you please share the code you are using to update the record and the Items properties of both the drop-down and the gallery.

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