Filters and Conditions
Use Adalo's built-in logic operators to filter records, create conditional actions, or change a component's visibility
Skill Level: Beginner
Before You Begin
Have a basic understanding of Databases, Screen & Components, and Actions
You do not need a paid Adalo plan to use this feature
Walkthrough
Introduction
Filters and conditions can be found in many of Adalo's components. Knowing how to use them effectively can open up a world of possibilities no matter where you use them! First let's define each term. Both of them run on what's called If-Then logic, meaning that if something is true, then do this thing.
Filters - These are used to, you guessed it, filter records that are being pulled from the database. It usually involves starting with lots of records and narrowing it down to just a few using the pre-programmed logic Adalo has available.
Conditions - These also use this pre-programmed logic, but instead of filtering records, conditions evaluate whether or not something should occur. In this case, we're working with only one record at a time. Conditions actually contain a filter to help make this possible.
Where to Find Filters
Filters are typically found in List components and components that display whole groups of records such as:
Lists
Counts
Dropdowns
Deck Swiper
Image Swiper
Calendar
Chart Kits
...and many more!
Where to Find Conditions
Conditions are typically found primarily in two places:
Visibility controls for components (check out this more detailed guide)
An action's Advanced settings. (check out this more detailed guide)
Filters
You can add a filter anywhere you see the +Filter or the +Add Another Filter button. In Lists, Charts, and other components you will notice that 1 filter is provided by default, but you can also add Custom Filters to combine logic and display very specific groups of records:
Using AND/OR Logic
Within filters you have the option to make custom filters be inclusive of each other, or exclusive of each other. For lists and charts that have multiple custom filters, you can choose whether all of those filters must be true in order to show records, or you can choose whether any of the filters are true. You can do this using the AND and OR logic for filters. In the example below, the Drops to be displayed in the list must both have NFT in the title and have Published set to true. More filters can be added, by clicking on the + AND button. In order for records to display, all of the filters joined with AND must be met.
You can also create filters using OR. In the example below, only the Drops with NFT or ETH in the title will be shown. Notice that you can still add AND filters within each group of filters and still have an OR filter as well. This makes it very easy to dial in specific groups of records to display!
Conditions
There are two main places where you can add conditions. One is in a component's visibility options and the other is in an action's advanced settings. For components visibility you can click on the more button for the component, then click on Change Visibility. To access conditional actions, just click on Show Advanced in the bottom of the action.
After clicking on these, you will see the dropdown option to make the visibility or action only happen either Always or Only Sometimes. If you set it to Only Sometimes, a filter will appear where you can use logic operators to determine when or if something should be shown or occur. In the example below, the action will only occur if the Logged In User is marked as an Admin in the database:
Logical Operators
Logical operators is just a fancy way of saying how Adalo determines what records to show or when something like visibility or an action should occur. They result in either being true or false - for example, either Adalo should (true) show records based on this operator or it should not (false). Both filters and conditions use operators to determine what do to with records, components, or actions.
Following the if-then logic mentioned earlier we can use logical operators within filters and conditions to instruct Adalo that "if this thing is true, then do this other thing". In the example below we are using the "Is equal to" operators to evaluate a text field (Email) to say we should only display a component if the Logged In User's email is equal to admin@app.com.
Operator Types
There are several types of operators, depending on the property types being compared. Explore the tabs below to see the operators for each database property type:
Operators:
Is equal to - This operator is case sensitive and the two pieces of text must match each other exactly - even if there is a hidden return or space in the text. This operator is very strict.
"Day" is equal to "day" = false "Day" is equal to "Day" = true
Is not equal to - This operator is also case sensitive and determines if the two pieces of text are different from one another - even by a space or return. This operator is very strict. Hint: it's often easier to exclude items that to determine if they match exactly.
"Day" is not equal to "day" = true Day is not equal to Day = false
Contains - This operator determine if a string of text contains another string of text. This operator is not very strict and not case sensitive, but can sometimes have unintended consequences if multiple records share the same text string. For example, test@gmail.com and gmail@test.com both contain "gmail" but they are not the same result. This also makes it great for searching for records in your app.
Day contains day = true Day contains Day = true
Tuesday contains Day = true
Learn More
You can even combine filters with the power of conditions to give even more control over what happens in your app. For instance, you may change the visibility of a component based on a filtered count of a collection of records in your database.
Currently conditional actions and conditional visibility can only have one filter attached to them, but filters for lists, counts, charts, and other components can have as many filters as you like.
If you have multiple filters on the same component or count, those filters use an AND logic, meaning that all the filters must be true in order for the record(s) to be shown. OR logic is something we are considering adding, but is not currently available at this time.
Many times conditional actions and conditional visibility can be used interchangeably to achieve the same end result or user experience even though the setup may differ slightly.
Help
If you need additional help with this article, you can always ask in our community forum! Be sure to paste the link to this article in your post as well!
Do you have a tutorial or help doc request? Let us know!
Last updated