cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
lroi7
Microsoft
Microsoft

How to compare a ComboBox SelectedItems to a text value

Hello Everyone! I hope whoever reads this is well.

 

I am building a PowerApps and I am trying to figure out how can I get a gallery to be filtered based on the selection of 3 controllers (ComboBox, Dropdown & List (no multiple selection)). I am trying to build a logic so that when ppl select options within these controllers, the gallery will populate the respective data but I am getting stuck with trying to apply a filter of the data based on the ComboBox. I want to be able to filter data based on the countries that ppl select through that ComboxBox but whenever I try, I get "Imcompatible types of comparison. These can't be compared 'Table', 'Text':

 

//This is for selected countries, all status and all request
If(CountryComboBox.SelectedItems.Result <> "All" And RequestTypeBox.Selected.Value = "All" And StatusList.Selected.'PCL/PCR/EEX Status' = "All",
Filter(TicketsCollection,'CountryCode(refer to dropdown list)'.Value = CountryComboBox.Selected.Result))

 

When I use CountryComboBox.SELECTED.RESULT it does take, but when choosing more than 1 country, it does not filter the data correctly.

 

PowerApps Error.png

PowerApps Error 2.png

ComboBox is tied to a collection called Collect(CountryView, Distinct(EDMTables,'Country Code - Dropdown')) - Coming from a SharePoint

 

Note sure if this is sufficient information. Hope someone can help!

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@lroi7 

Yes, you are trying to compare a Table to Text - this will always be incompatible.  SelectedItems is a table.

 

In general, you would want to see if a text value is "in" a table - So If("All" in CountryComboBox.SelectedItems.Result ...  would be looking for a particular text in a table of records - in your case a single column table of Result values.

 

What is the entire formula you have for your Items property of the Gallery (in Text)?  From the picture, it looks like you are doing multiple filters in the formula - this should be avoided as it overcomplicates your formula and can cause schema issues if one filter is off.

 

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!

View solution in original post

2 REPLIES 2
RandyHayes
Super User
Super User

@lroi7 

Yes, you are trying to compare a Table to Text - this will always be incompatible.  SelectedItems is a table.

 

In general, you would want to see if a text value is "in" a table - So If("All" in CountryComboBox.SelectedItems.Result ...  would be looking for a particular text in a table of records - in your case a single column table of Result values.

 

What is the entire formula you have for your Items property of the Gallery (in Text)?  From the picture, it looks like you are doing multiple filters in the formula - this should be avoided as it overcomplicates your formula and can cause schema issues if one filter is off.

 

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!

View solution in original post

lroi7
Microsoft
Microsoft

Hello Randy!

 

Thanks for the prompt response (apologies for my not so prompt reply). Your suggestion was very helpful to me, it allowed me to search in the table correctly which was awesome, the way I was doing was definitely not correct. Couldn't figure out any other way of applying the filtering of the gallery based on 3 different controllers + a search input, so I still kept the logic of multiple filters (I almost had a stroke trying to make it work) but it all work out fine :), here's the rest of the formula in case you still want to see it (any other feedback/advise will be very much appreciated).

 

Search(
    SortByColumns(
If(
//This is for all countries, all status and all request
"All" in CountryComboBox.SelectedItems.Result And RequestTypeBox.Selected.Value = "All" And StatusList.Selected.'PCL/PCR/EEX Status' = "All",
TicketsCollection,

//This is for selected countries, all status and all request
Not("All" in CountryComboBox.SelectedItems.Result) And RequestTypeBox.Selected.Value = "All" And StatusList.Selected.'PCL/PCR/EEX Status' = "All",
Filter(TicketsCollection, 'CountryCode(refer to dropdown list)'.Value in CountryComboBox.SelectedItems.Result),

//This is for selected status, all countries and all request
Not("All" in CountryComboBox.SelectedItems.Result) And RequestTypeBox.Selected.Value = "All" And StatusList.Selected.'PCL/PCR/EEX Status' <> "All",
Filter(TicketsCollection, 'PCL/PCR/EEX Status'.Value in StatusList.SelectedItemsText.Value),

//This is for selected request, all countries and all status
Not("All" in CountryComboBox.SelectedItems.Result) And RequestTypeBox.Selected.Value <> "All" And StatusList.Selected.'PCL/PCR/EEX Status' = "All",
Filter(TicketsCollection, RequestType.Value in RequestTypeBox.Selected.Value),

//This is for selected request, selected countries and selected status
Not("All" in CountryComboBox.SelectedItems.Result) And RequestTypeBox.Selected.Value <> "All" And StatusList.Selected.'PCL/PCR/EEX Status' <> "All",
Filter(TicketsCollection, RequestType.Value in RequestTypeBox.Selected.Value And 'PCL/PCR/EEX Status'.Value in StatusList.SelectedItemsText.Value And 'CountryCode(refer to dropdown list)'.Value in CountryComboBox.SelectedItems.Result),


//This is for selected status, all countries and all request
"All" in CountryComboBox.SelectedItems.Result And RequestTypeBox.Selected.Value = "All" And StatusList.Selected.'PCL/PCR/EEX Status' <> "All",
Filter(TicketsCollection, 'PCL/PCR/EEX Status'.Value in StatusList.SelectedItemsText.Value),

//This is for selected request, all countries and all status
"All" in CountryComboBox.SelectedItems.Result And RequestTypeBox.Selected.Value <> "All" And StatusList.Selected.'PCL/PCR/EEX Status' = "All",
Filter(TicketsCollection, RequestType.Value in RequestTypeBox.Selected.Value),

//This is for selected request, selected countries and selected status
"All" in CountryComboBox.SelectedItems.Result And RequestTypeBox.Selected.Value <> "All" And StatusList.Selected.'PCL/PCR/EEX Status' <> "All",
Filter(TicketsCollection, RequestType.Value in RequestTypeBox.Selected.Value And 'PCL/PCR/EEX Status'.Value in StatusList.SelectedItemsText.Value)),



"Title",
If(SortDescending1,Descending,Ascending)), SearchBox.Text,"Title","Title")

 

GifMaker_20211014010343368.gif

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 (3,037)