cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
misc
Resolver II
Resolver II

Filter by dropdown, then by text search box

I've watched videos and looked at all other posts I could find about this but I'm just having no luck. Not sure what I'm doing wrong but appreciate any help.

 

I have a dropdown which should filter the gallery by the 'Report type' column (field called Reptype in the gallery), I then want the search text box to search through the other fields to narrow it down further. 

 

I can't guarantee how long the data list will be overall, and so I want to avoid using non-delegatable functions where possible, but I thought if I filter it first then do the non-delegatable search on the data returned it will be ok (there will never be over 2000 records under each report type).

 

My first hurdle is the dropdown (ReportTypeDpd) filter. I cannot get this to work at all. I have tried loads of different ways but the closest I got to anything that worked was: 

Filter(Incidents, ReportTypeDpd.Selected.Value in Reptype)

 1) This gives an error on every field in the gallery saying it's a 'circular reference' 

2) This is non-delegatable so really I want to use = or something else delegatable, but all of those threw the 'invalid argument type' error.

 

Second hurdle:

I have a search function which works by itself for the search box:

Search(Incidents, SearchBox.Text, "Title")

However if I try to add more fields to this search either as 'subtitle' or by the field name such as 'Refno' this returns blank and breaks the search altogether. Everything I found online suggested just adding the new fields should work so I have no idea why it won't eg.:

Search(Incidents, SearchBox.Text, "Title", "Refno")

  

Unsurprisingly then, when I have tried to do the full Filter/Search I get thrown errors or it just returns nothing.

gallerysort.png

I need the function to do the following:

If ReportTypeDpd = "All reports" show the full gallery

If ReportTypeDpd = "Incident Reports", "Building Reports", "Fire Reports", Filter the Gallery by the data in the 'Reptype' field

ALSO

Search all the Gallery fields (Reptype, Refno, Building, Campus, Date, Cat, Subcat) for any text typed into the SearchBox.

 

I can never get my head around the Filter/Search/Sort functions so please help! 

1 ACCEPTED SOLUTION

Accepted Solutions

I have managed to figure out the nesting Filter/Search, this below is working fine:

incidentsearch.png

My only remaining question therefore is the one about searching Choice columns - is this possible in any way?

View solution in original post

5 REPLIES 5
rsaikrishna
Dual Super User
Dual Super User

@misc 

 

Change your Filter function as below:

Filter(Incidents, Reptype = ReportTypeDpd.Selected.Value)

 

Reptype: This should be the field/column in Incidents data source.

 

Regarding Search function:

 

Search( Table, SearchString, Column1 [, Column2, ... ] )

  • Table - Required. Table to search.
  • SearchString - Required. The string to search for. If blank or an empty string, all records are returned.
  • Column(s) - Required. The names of columns within Table to search. Columns to search must contain text. Column names must be strings and enclosed in double quotes. However, the column names must be static and cannot be calculated with a formula. If SearchString is found within the data of any of these columns as a partial match, the full record will be returned.

 

Please check the text highlighted in bold. Make sure your Search function contains the fields accordingly.

 

 

Regards

Krishna Rachakonda

If this reply helped you to solve the issue, please mark the post as Accepted SolutionMarking this post as Accepted Solution, will help many other users to use this post to solve same or similar issue without re-posting the issue in the group. Saves a lot of time for everyone.

Thanks, but neither of those seem to work.

 

For the Filter, I try it by itself and get the following. As per your suggestion I changed the 'Reptype' (name of the field box in the Powerapp) to the name of my SharePoint Column 'Report Type'. I get the error you can see, 'invalid argument type' and when I click in the function bar the = sign has a red squiggle under it.

galleryfilter.png

 

When I try the Search by itself, again it works for the basic search I mention above, but when I go to add new column names it throws an error that the column doesn't exist:

gallerysearch.png

However, as you can see from this screenshot of my list settings, it clearly does:

gallerySP.png

Your comment "Columns to search must contain text" made me wonder if it's because the column types are either Choice or Multiple lines of text, but I have tried with a column that's single line of text too with the same error.

EDIT: I have played around more and I've managed to get the 'sub-location' column to work by using 'Sub-x002d_location' instead, so I am guessing this issue is related to the fact the other columns are not text columns which is very frustrating.

 

Anything I'm missing?

 

EDIT AGAIN:
After more playing I've managed to get the Filter side working: 

If(ReportTypeDpd.Selected.Value = "All reports", Incidents, Filter(Incidents, 'Report type'.Value = ReportTypeDpd.Selected.Value))

 

So my next questions are:
1) Is there definitely no way that I can use 'Search' on a Choice column? I have tried doing .Value like I had to for Filter but no luck

2) How do I combine the Filter function above with my Search function, does the Search precede the IF or follow it?

Search(Incidents, SearchBox.Text, "Title", "Sub_x002d_location")

 

poweractivate
Super User II
Super User II

1) First you should start at the beginning and check this first

 


@misc wrote:

 

I can't guarantee how long the data list will be overall, and so I want to avoid using non-delegatable functions where possible, but I thought if I filter it first then do the non-delegatable search on the data returned it will be ok (there will never be over 2000 records under each report type).

 

 


 

Which do you mean?


#1A) Do you mean that a filter query from Power Apps will never return more than 2,000 records?
#1B) Or, do you mean that the total number of records, even without filters, is guaranteed always to be 2,000 or less records?

 

If you meant A, then watch out. The delegable limit applies not on the maximum filtered number of records that the non-delegable query can return, but actually applies on the total number of records,. 

 

So if you have 2,001 records, only the first 2,000 records are seen and even checked for a match, so 1 record may have a high chance to always be left out of the result altogether, even if it would have matched. If it is the 2001'th record and it matches, a non-delegable query will guarantee that it will always leave it out.

 

Consider now this example. If you have 10,000 records, only the first 2,000 records are seen, so a whopping 8,000 records may have a high chance to always be left out of the query, even if it would have matched. Suppose that only two of your 10,000 records match the filter - sure, that's below 2,000 records - however, suppose these two records are what PowerApps considers the 9998th and 9999th record. Then a non-delegable query will always skip those records, so there is a guarantee of a match of zero records every time with a non-delegable query, not the expected two records.

 

Moreover, when attempting to use a delegable query to bring it under 2,000 then use a non-delegable one after that, be very careful with that. It is possible that it will not work as expectedif even a part of the query is non-delegable.

 

Note that the default is 500 though, not 2,000. We presume you changed it to the max, of 2,000 - remember that the default is actually 500. Even if you changed it to 2,000, you should try to avoid any kind of non-delegable situation altogether.

 

Also, you want to check the connector documentation for the connector you are using. If the data source is non-delegable, no warning will show, but in that case, it is actually any use of the data source that is a gigantic "delegation warning"

 

More info on Delegation -> Understand delegation in a canvas app (docs.microsoft.com)

 

2) Regarding why suggestion from @rsaikrishna did not work in your case:

 

Actually, we are not so sure why it did not work, other than maybe Item #2B below.


This one we might have to check it further, but it may be related to your data source(s).

 

#2A) Which data source(s) is/are you using?
#2B) In the data source, does the "Sub-location" actually exist over there? Try to see if checking as the error message suggests and seeing if it may be actually missing from the data source gives any further indication of the issue.

 

Other than the above, we might need to check on it with more context and information from you.


We might come back and check through your original post in more detail to see if there was anything more that stood out. In meantime @rsaikrishna please feel free to check on it as well and possibly advise @misc of a solution.

Morning,

 

So I had thought that if I have two functions they would work one after the other so I could use a delegatable function first to definitely filter the list down to less than 2000, and then use the non-delegatable function on that smaller list. Evidently I'd misunderstood there. Having reviewed the current format however, we're only just over 1000 records for the year so would actually expect the limit of 2000 to be more than enough. 

 

In answer to your second question I am using a Sharepoint list. I actually edited my comment above with a few updates once I'd played around a little more and figured out the reason why rsaikrishna's reply didn't work - because it is a choice column I needed .Value in there after the column name.

 

With the Search, I needed to use the column name with _0200d etc. rather than just single quote marks and it worked for one of the columns which was Multiple lines of Text. It seems my issue with the Search is that I have Choice columns not text columns. Is there any way I can make this work regardless?

 

If not, I will cope with only being able to search a few of the fields (though it is frustrating), I just need to understand how to 'merge' the two.

I have managed to figure out the nesting Filter/Search, this below is working fine:

incidentsearch.png

My only remaining question therefore is the one about searching Choice columns - is this possible in any way?

View solution in original post

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

Top Solution Authors
Top Kudoed Authors
Users online (89,205)