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

Combobox frustration

I have a Combobox (need multi-select in dropdown format), that displays 2 columns of data.

 

Country and Region are the columns in the combobox but not all countries have regions associated with them.

In another place I need to have a label that shows the items selected from the combobox.   I can do this:

 

Concat(ComboBoxCountry.SelectedItems, Country & " - " & Region & " 
")

 

And I will get this.

ConcatCBox.png

 

What I would like to do is have an If statement that checks to see if the Region is blank and chooses either of the below options so countries with no associated regions appear without the dash.

 

 

Concat(ComboBoxCountry.SelectedItems, Country & " - " & Region & " 
")

 

 

Or

 

 

Concat(ComboBoxCountry.SelectedItems, Country & "")

 

 

I suspect I need to use a with function, but am just not experienced enough with that to make it work, I tried.

 

@RandyHayes 



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
CNT
Super User
Super User

@JR-BejeweledOne If you don't want the dash for countries without a region, try this,

Concat(ComboBoxCountry.SelectedItems, Country & If(!IsBlank(Region), " - " & Region) & " 
")

View solution in original post

5 REPLIES 5
CNT
Super User
Super User

@JR-BejeweledOne If you don't want the dash for countries without a region, try this,

Concat(ComboBoxCountry.SelectedItems, Country & If(!IsBlank(Region), " - " & Region) & " 
")

View solution in original post

Thanks, I should have known it was something much more simple than I was trying to do.   It's been a Monday for sure.

 

Maybe you can answer this question as well.

 

My combobox is getting it's items from a collection called Holidays.   This is the Items property.

 

Sort(
GroupBy(Holidays,
"Country", "Region", "Result"
), Country, Ascending)

 

I only need one instance of a country or country/region pair to show in the list.   I currently have the Combobox displaying 2 columns, Country and Region.   Both are needed to properly filter the holidays in the data tables.

 

However if, for example, there are multiples for a single country, the region can be seen when selecting but it doesn't show in the top section.   So one wasn't desired, knowing which one to uncheck would be problematic.

 

Combobox1.png

 

 

What would be ideal is to use the AddColumns, in conjunction with the previous formula and add a DisplayName column that concat's the Country and Region (if it is there).   I tried multiple versions with limited success.    I couldn't get the syntax correct.  



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.

@JR-BejeweledOne Please try this,

 

Sort(AddColumns(GroupBy(Holidays, "Country", "Region", "Result"), "CountryAndRegion", Country & ", " & Region)), Country, Ascending)

This is how it looks,

CNT_0-1621886090488.png

 

 

Please remember to give a 👍 and accept the solution as it will help others in the future.

Talk about strange.

 

When I use your formula above, it complains.

ComboBoxError1.png

 

It doesn't like the extra close paren at the end of the AddColumns, as you can see below after I removed it.

 

Combobox2.png

 

However I still get the extra "-".   It doesn't matter if I use ", " or " - ", there is an extra one at the end of the Country when no Region is attached.

 

combobox3.png

 

 

Turns out this works:

 

Sort(
     AddColumns(
       GroupBy(Holidays,
        "Country", "Region", "Result"),
          "DisplayName", Country & If(!IsBlank(Region), " - " & Region)),
             Ascending
            )


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.

@JR-BejeweledOne Glad it works! Hope u'r Monday isn't blue anymore 😊!

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

secondImage

Power Apps Community Call

Please join us on Wednesday, October 20th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

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