‘No results found’ feature

Hey,

I have a collection with a search bar and the searching works pretty well. I have also on another app created my own search bar with filters using some of the tutorials from this community, which also works great searching collections.

However, on both of these, if a user is too specific and nothing is found - the collection is blank. Just asking, is there any clever sheet formula or something for displaying a ‘no results found’ text or image. Would make my UX better.

Cheers,
Josh

Possible with the custom search, but not possible (as far as I’m aware) with the native search.

With the custom search, it depends how you are applying your filtering, but essentially what you need to do is a rollup to count the number of matches. Then if the number of matches is zero, use a visibility condition to expose your “No results” message.

2 Likes

I think you could do it with the Native search if the following conditions are right…

  1. Your screen is custom (so you can add a text component)

  2. The source of your collection is a relation

In your collection the visibility setting would be ‘if relation collection → is not empty’

In the text component ‘if relation collection → is empty’

hmm, I don’t think that will work.
The native search isn’t going to change the relation, so even if you enter a search term that results in zero results, the relation will remain unchanged (ie. not empty).

1 Like

@Darren_Murphy is right. I was definitely thinking of a different use case :man_facepalming:

1 Like

@Darren_Murphy Any tutorials on this that you know of?

Not specifically that I am aware of. But it is fairly straight forward.
As I mentioned, it depends how you are currently applying the custom filtering.

Can you show or explain how you are applying that?
I can probably lead you from there…

I’ve used this method for custom search bar and filters:

So basically I am using a ‘current user’ table with user-specific columns. I am then filtering the displayed items in a collection by those selected columns.

If you could help me to where and how to set up a rollup column that would be amazing.

Thanks

1 Like

Okay, I see.

To do what I suggest you will need to make an adjustment to the way your filtering is applied.
Instead of applying all the filter conditions to the collection, you build the filtering logic in the underlying data table, and then use a single filter condition on your collection.

Here is how you do that:

  • In your data table (the source of your collection) you need to add a series of Single Value columns. The purpose of these is to take the values in your Current User table and apply them to all rows in your data table. You need one for each user specific filter column in your Current User table.
  • You then build an if-then-else column by comparing those single value columns to your actual data. The if-then-else column should return true for each row that matches. I can’t tell you exactly how to construct that, as I can’t see your data. But if you show me the current filter conditions on your collection, I can tell you how to translate it to an if-then-else column.
  • Once you have the if-then-else column, you use that to filter your collection, only showing rows where that column is checked.
  • And to count the number of matching records, you do a rollup on the if-then-else column, counting the true values.
1 Like

@Darren_Murphy Thanks that sounds awesome. One question - if two people were searching at the same time, changing those single value columns in the data table would surely alter the other users search results?

Thanks again

It will not be a problem if the search and filter values, that the single value columns are referring to, are being stored in User Specific Columns.