cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Al12397
Regular Visitor

Adding an 'NA' option to a comboBox along with the original data

Lets Say I have a datasource with all the countries and their corresponding states/proveniences and the states has been populated in my combobox like the following

Distinct(Filter(tbl_Country, 'Country' = First(cb_Country.SelectedItems).Result),'StateName')
- the filter is there because the user can choose a country which filters a states combobox

Now I have a requirement to add an "NA" option to my comboBox but I cant change the underlying data. Meaning I cant go to datasource and add NA manually to the table. How can I add the 'NA' option along with the rest of the data to my combo box. Secondly Can I have the NA option appear first?

2 ACCEPTED SOLUTIONS

Accepted Solutions
TheRobRush
Super User
Super User

in this video @RandyHayes shows you how to add a "All" option to a dropdown. Same basic idea can help you add any other option you want, and set it's behavior.

 

https://www.youtube.com/watch?v=nlfZD6lsCDc 

_____________________________________________________________________________________
Like my answer? - Hit that Thumbs Up. Resolved the Issue? - Hit Accept as Solution.
This helps others find solutions to future issues!

View solution in original post

Anonymous_Hippo
Resolver I
Resolver I

Put this code on Start of the App

ClearCollect(
    CollCountry,
    {Result: "NA"}
);
Collect(
    CollCountry,
       Distinct(Filter(tbl_Country, 'Country' = First(cb_Country.SelectedItems).Result),'StateName')
)

 

And on the Items property of the DropDown put CollCountry

 

I made a test case and this should work 🙂

View solution in original post

3 REPLIES 3
LRVinNC
Super User
Super User

In similar circumstances, I have loaded the values for my combobox to a collection, then patched the collection to add the N/A value, using a leading space so it sorted to the top of the list, and then used that collection instead of the original table.  

LRVinNC

------------------
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.
TheRobRush
Super User
Super User

in this video @RandyHayes shows you how to add a "All" option to a dropdown. Same basic idea can help you add any other option you want, and set it's behavior.

 

https://www.youtube.com/watch?v=nlfZD6lsCDc 

_____________________________________________________________________________________
Like my answer? - Hit that Thumbs Up. Resolved the Issue? - Hit Accept as Solution.
This helps others find solutions to future issues!

View solution in original post

Anonymous_Hippo
Resolver I
Resolver I

Put this code on Start of the App

ClearCollect(
    CollCountry,
    {Result: "NA"}
);
Collect(
    CollCountry,
       Distinct(Filter(tbl_Country, 'Country' = First(cb_Country.SelectedItems).Result),'StateName')
)

 

And on the Items property of the DropDown put CollCountry

 

I made a test case and this should work 🙂

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 (2,669)