cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JR-BejeweledOne
Super User
Super User

Using ComboBox Default Selected Item

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.   

 

 



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.
1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@JR-BejeweledOne 

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

{Result:
    With(Office365Users.MyProfileV2(),
       If(country in Distinct(Holidays, Country), 
           country, 
           Blank()
       )
   )
}
_____________________________________________________________________________________
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.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

7 REPLIES 7
WarrenBelz
Super User
Super User

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.

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



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.
RandyHayes
Super User
Super User

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

_____________________________________________________________________________________
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.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

It is not multi-select. 



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.
RandyHayes
Super User
Super User

@JR-BejeweledOne 

Then your DSI formula should be:

{Result:
    With(Office365Users.MyProfileV2(),
    If(country in Distinct(Holidays, Country), 
        country, 
        Blank()
    )
}
_____________________________________________________________________________________
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.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

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



If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.
RandyHayes
Super User
Super User

@JR-BejeweledOne 

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

{Result:
    With(Office365Users.MyProfileV2(),
       If(country in Distinct(Holidays, Country), 
           country, 
           Blank()
       )
   )
}
_____________________________________________________________________________________
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.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,808)