cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
luvagoldenk9
Helper III
Helper III

Combo Box - Sort Selected Items Ascending

Hi,

 

I have a combo box that is based on a Share Point Choice field. The field called ColorsSelected displays the Share Point list combo box values display in ascending order as each choice is entered into the Share Point list:

Aqua

Blue

Green

Red

Violet

Yellow

 

If a user selects Red then Blue, the 2 items show as selected (Red, Blue) and that is how they are saved when I patch the data to back to Share Point.

 

I need to patch the selected combo box values in ascending order (Blue, Red). I know SortByColumns cannot be used with Choice fields so I used the Sort command. However it is not sorting the selected items back in ascending order: 

ColorsSelected: Sort(comboboxColors.SelectedItems,"Ascending")

 

Does anyone know if this is possible? Thank you!!

1 ACCEPTED SOLUTION

Accepted Solutions
v-qiaqi-msft
Community Support
Community Support

Hi@luvagoldenk9,

Based on the issue that you mentioned, do you want to patch the sorted selected colors to the SP list?

Could you please tell me that if the Combo Box is allowed multi select?

I have a test on my side, please take a try as below:

Add a Button and set the OnSelect property as below:

 

Patch(
    'YourSPList',
    Defaults('YourSPList'),
    {
        'ColorsSelected ': Sort(
            ComboBox4.SelectedItems,
            Text(Value),
            Ascending
        )
    }
)

 

Note: In my scenario, I add a Gallery to display the 'ColorsSelected' column on time once it is updated.

121801Gif.gif

Regards,

Qi

Best Regards,
Qi

View solution in original post

3 REPLIES 3
RandyHayes
Super User
Super User

@luvagoldenk9 

Please consider changing your Formula to the following for the update to your Choice field in SharePoint:

ForAll(SortByColumns(comboboxColors.SelectedItems, "Value"), 
   {Value: Value, 
   '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference"
   }
)

This will sort the values and provide the proper information to update the SharePoint column.

I will be assuming that your Choice column allows for multiple selections.

 

I hope this is helpful for you. 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
v-qiaqi-msft
Community Support
Community Support

Hi@luvagoldenk9,

Based on the issue that you mentioned, do you want to patch the sorted selected colors to the SP list?

Could you please tell me that if the Combo Box is allowed multi select?

I have a test on my side, please take a try as below:

Add a Button and set the OnSelect property as below:

 

Patch(
    'YourSPList',
    Defaults('YourSPList'),
    {
        'ColorsSelected ': Sort(
            ComboBox4.SelectedItems,
            Text(Value),
            Ascending
        )
    }
)

 

Note: In my scenario, I add a Gallery to display the 'ColorsSelected' column on time once it is updated.

121801Gif.gif

Regards,

Qi

Best Regards,
Qi

Thank you for pointing the missing parameter. I needed to add the 'Text(Value)' to my Sort statement and it worked!

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (2,974)