When you show the contents of a table in your app, you do not need to show every row and every column. Instead, you can 'slice' the data, choosing a subset of the columns and a subset of the rows.
By default, the app utilizes all the columns and all the rows. But this is something you can change in the app editor by adding a new Slice. You get to specify the subset of columns included and a row filter condition that determines which rows get included in the slice. Remember, once you define the slice, you still need to use this slice in a UX view (usually, you would replace the source data of an existing view over a table to instead use the newly defined slice over the table).
Filtering rows based on the user
You can choose to filter data based on the user who is currently using the app. In order to do this, you first need to make sure your app requires sign-in, so AppSheet can recognize who is signed in to the app and render the corresponding data.
You'll also need to make sure that your spreadsheet contains a qualifying column that can uniquely identify the user based on the row. The contents of that column should identify the user-- Email is always best, but you could use Name, Student, User, etc., anything that will require the user to type in the qualifying detail.
Then you will need to implement slices.
When you create a slice, you need to decide the row filter condition. In the case of our Class Assignments sample app, we've sliced the data based on the USERNAME, which is specified in the column "Student".
Since the app requires sign-in, a student's name will be identified via the email from which the user is logged in to the app.
Avoid USERNAME() because it is unreliable. Providers like Google, only return the user's name if that user has enabled Google+ on their account. Instead use an Email column and compare it with USEREMAIL() rather than comparing a Name column to USERNAME().
Rich filter conditions
Rich filter conditions give you the ability to express simple or complex criteria. Most commonly, you want to combine a couple of conditions with an AND or an OR. There are two ways to do this:
- Insert an AppSheet expression in the Slice Row Filter Condition. This permits you to write slices with rich filter conditions. You may use any arbitrary AND/OR/NOT condition to define the row filter for the slice. For example, to include rows with a DateColumn value in the next 7 days use the following formula: AND([_DateColumn] >= TODAY(), [_DateColumn] < TODAY()+7). To filter on an EmailColumn use this formula: [EmailColumn] = USEREMAIL().
- Use spreadsheet formulas: Spreadsheets already have a wonderfully expressive formula language. So if you need complex expression logic, consider adding an additional spreadsheet column that is computed via a formula expression. Then use that column in a simple AppSheet slice filter condition. Please be aware that the spreadsheet formulas are only computed when you sync changes to the backend-- i.e. they do not run dynamically in your app.
Using multiple slices
Richer apps can use more than one table slice.
In the Data>Slices tab, click on 'New Slice' to add another data slice. It automatically gets added to your app when you save your changes. You can now define control views over this slice as well.
Table slices have a source table, an optional row filter condition, and optionally specify a subset of columns.
Please be careful editing table slice definitions. Slices without a source table or with an invalid source table name will lead to errors in your app.