What is a Yes/No column?
A Yes/No column is similar to a Choice column but only allows for two values. Those two values are named yes and no by default. However, the labels can be changed. We will use the Students table to review yes/no columns. To review the data model, click here.
Displaying choices in a dropdown
We will use the International? column on the Students table as an example. To display the list of options available for the International? column in a dropdown or combo box (cmbInternational), set the Items property to:
Choices('International? (Students)')
Just like a local choice, the syntax for a yes/no column is the column name followed by the table name in brackets.
To learn more about the Choices function, click here.
Filtering using a list
Add a gallery galStudents. Then set its Items property to the Students table. We will use the same cmbInternational to filter the list of students based on their major.
To filter the list of students, set the Items property of galStudents to:
Filter(
Students,
'International?' = cmbInternational.Selected.Value
)
Let's breakdown the filter condition:
- The first part checks if the combo box is blank, if it is, then the filter condition becomes true and all records are returned.
- Then the second part (to the right of the ||) comes into play when the combo box isn't blank. Only those students are returned that match the selected value for the International? column.
Filtering by a specific value
To filter by a specific value, set the Items property of a gallery to:
Filter(
Students,
'International?' = 'International? (Students)'.Yes
)
As you can see, a yes/no column is referenced just like a local choice i.e. it is referenced by the column name followed by the table name in brackets.
Patching a Yes/No column using a list
To patch a student record, set the OnSelect of a button to:
Patch(
Students,
Defaults(Students),
{'International?': cmbInternational.Selected.Value}
)
Since a Yes/No column only has two values, sometimes using a toggle makes more sense. So to patch a student record using a toggle for the International? column, set the OnSelect of a button to:
Patch(
Students,
Defaults(Students),
{'International?': cmbInternational.Selected.Value}
)
Patching a Yes/No column using a specific value
To patch a student record using a specific International? value using a toggle, set the OnSelect of a button to:
Patch(
Students,
Defaults(Students),
{
'International?': If(
tglInternational.Value,
'International? (Students)'.Yes,
'International? (Students)'.No
)
}
)
1 thought on “How to work with Yes/No columns in Dataverse”