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

Announcements

News and Announcements icon
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
    155,279 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,299 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,299 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,299 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 1,074

#2
Valantis Profile Picture

Valantis 639

#3
11manish Profile Picture

11manish 606

Last 30 days Overall leaderboard