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) & " 
")

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
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (4,283)