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 / Using ComboBox Default...
Power Apps
Answered

Using ComboBox Default Selected Item

(0) ShareShare
ReportReport
Posted on by 5,836 Moderator

EDITED:  I am trying to replace a dropdown with a Combobox.  The Combobox is working fine with a default value,  but, I am unable to use that default value.

 

ComboBox Items:  Sort(Distinct(Holidays, Country), Result, Ascending)

ComboBox DefaultSelectedItems:  [If(!IsBlank(Office365Users.MyProfileV2().country) && Office365Users.MyProfileV2().country in Distinct(Holidays, Country), Office365Users.MyProfileV2().country, "")]

 

If I do CountRows(ComboBoxCountryFY.SelectedItems) I get a return of 1.  So there is one item in the Combobox.      In trying to set a label (for testing purposes) to the value of the Combobox, I don't get anything.

 

combobox.jpg

 

ComboBoxCountryFY.Selected.Result returns nothing

ComboBoxCountryFY.SelectedItems gives an error

ComboBoxCountryFY.SelectedItems.Result gives an error

First(ComboBoxCountryFY.SelectedItems.Result) gives an error

First(ComboBoxCountryFY.SelectedItems).Result doesn't give an error but also doesn't return anything

 

I am out of ideas.   

 

 

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    153,079 Most Valuable Professional on at

    Hi @JR-BejeweledOne ,

    Try

    If(
     !IsBlank(Office365Users.MyProfileV2().country) && 
     Office365Users.MyProfileV2().country in Distinct(Holidays, Country), 
     {Result:Office365Users.MyProfileV2().country}
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • JR-BejeweledOne Profile Picture
    5,836 Moderator on at

    I presume you mean in the DefaultSelectedItems?   It should not populate a country that doesn't exist in the list.

     

    For the bigger picture, this is a Holiday Calendar.   The ComboBox provides the list of countries from the Holiday Schedule table.   The country in the ComboBox is then used to display the Holidays for the selected country.

     

    The goal is to dynamically display the holidays for the person using the app.   It works beautifully with the dropdown.  Because we have such a long list of countries, we have been asked to provide a text input filter.   I can certainly add a text box and do it that way, but thought that the built-in search feature of the ComboBox would be the most logical way to do it.

     

    If I use this in the default selected Items, I get this:

     

    combobox1jpg.jpg

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

    @JR-BejeweledOne 

    I assume that since you are designating the DSI (DefaultSelectedItems) to be a table that your combobox is a multi-select combobox.

     

    To get a selection in a Combobox - the schema of the records in the DSI *must* match the schema of the Items property.

    Your Items property is a table with a single column called Result.  You need to match that in the DSI.

     

    So, your formula should be:

    [
     With(Office365Users.MyProfileV2(),
     If(country in Distinct(Holidays, Country), 
     {Result: country}, 
     Blank()
     )
    ]

    You really don't need to check for !IsBlank on the country - unless your Holidays list contains blank countries.

    The above formula will produce a table with a single record that has a single column of Result...which will match your Items property correctly.

     

    I hope this is helpful for you.

  • JR-BejeweledOne Profile Picture
    5,836 Moderator on at

    It is not multi-select. 

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

    @JR-BejeweledOne 

    Then your DSI formula should be:

    {Result:
     With(Office365Users.MyProfileV2(),
     If(country in Distinct(Holidays, Country), 
     country, 
     Blank()
     )
    }
  • JR-BejeweledOne Profile Picture
    5,836 Moderator on at

    What am I missing?    I get this:  Unexpected Characters: The forumula contains 'ParenClose' where 'CurlyClose' is expected.  

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

    @JR-BejeweledOne 

    Oops...missed a closing paren,  Should be:

    {Result:
     With(Office365Users.MyProfileV2(),
     If(country in Distinct(Holidays, Country), 
     country, 
     Blank()
     )
     )
    }

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 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard