Filter functions in a Canvas app are used to filter records from a data source based on a specific condition or set of conditions. In a Canvas app, we can use various filter functions to manipulate data before displaying it to users.
Here are some of the commonly used filter functions in a Canvas app:
- Filter: The Filter function is used to return a filtered table based on the specified condition. It returns all the records in a table that meet the specified condition.
Example: Filter(customers, StartsWith(Name, “A”))
This example returns all the records from the “customers” table where the “Name” column starts with the letter “A”. - Search: The Search function is used to search for a specific string in a table. It returns all the records in a table that contain the specified string.
Example: Search(customers, “John”)
This example returns all the records from the “customers” table where the “Name” column contains the string “John”. - Lookup: The Lookup function is used to return a single record from a table based on a specific condition. It returns the first record in a table that meets the specified condition.
Example: Lookup(customers, Id = 1)
This example returns the first record from the “customers” table where the “Id” column equals 1. - Sort: The Sort function is used to sort the records in a table based on a specific column. It returns the sorted table.
Example: Sort(customers, Name, Ascending)
This example sorts the “customers” table by the “Name” column in ascending order. - Distinct: The Distinct function is used to return a table with unique values based on a specific column. It removes all the duplicate values from a table.
Example: Distinct(customers, Country)
This example returns a table with all the unique values from the “Country” column of the “customers” table. - First: The First function is used to return the first record in a table. It can be used to return a specific value from a table.
Example: First(customers).Name
This example returns the value of the “Name” column of the first record in the “customers” table. - Last: The Last function is used to return the last record in a table. It can be used to return a specific value from a table.
Example: Last(customers).Id
This example returns the value of the “Id” column of the last record in the “customers” table.
These are just a few examples of the filter functions that you can use in a Canvas app. There are many more functions available that you can use to manipulate data in your app.