Dataverse - How to create and use Dataverse views in Canvas Apps

A feature of Dataverse is the ability to define server side views. A view is a named query that Dataverse executes on the server.

One of the key benefits of a view is that we can extract/encapsulate complex query expressions in a way that is re-usable between both canvas and model driven apps.Multiple canvas apps can display data from the same view. We can update the view definition in a single place and this change will apply to all apps. This saves us from needing to make changes accross multiple apps

This post provides a quick walk through on how to create a view, and to use it from a canvas app.

How to create a Dataverse view

We create a view by opening the table designer from the Maker Portal. Here, we find the option to add a new view from the view tab. From the view designer, we can specify the filter criteria and the sort order of the output.


Unlike SQL Server, the supported view definitions are relatively simple. It is not possible to define views that traverse multiple levels of tables, or to union other tables.

How to display the contents of a Dataverse view in a gallery

From a canvas app, we can configure a gallery control to display the contents of a Dataverse view. To do this, we set the Items property of the gallery to the underlying table. A 'Views' setting appears beneath the table. From here, we can select one of the available views. Note that the 'views' property appears only with the gallery control. The views setting is not available when we set a data table or combo box control to a Dataverse table.

How to access a Dataverse view from formula

We can access Dataverse views in formula by calling the Filter function. We pass the table name as the first argument, and the view name as the second argument.

As an example, here's how to configure the Items of a listbox control to displays records from a view called 'PDF documents'. This view is based on the "PropertyDocuments" table.

We access the available views through an enumeration that's named after the source table with the suffix (Views). As this screenshot beneath shows, the formula bar provides code completion that shows the available views.
 
Filter(PropertyDocuments,
'PropertyDocuments (Views)'.'PDF Documents'
)

It's possible to combine additional criteria in the call to Filter function. As an example, here's how to append an additional condition to return only records from the view that were created within the past 30 days.
 
Filter(PropertyDocuments,
'PropertyDocuments (Views)'.'PDF Documents',
'Created On' > DateAdd(Now(), -30)
)

Conclusion

With Dataverse, we can query and filter data through views. In this post, we looked at how to create a view, how to display data from a view in a canvas apps, and how to refer to views in formula.

Related posts

Dataverse - How to set yes no values with checkbox- Walkthrough
January 29, 2025
Dataverse - Add image column missing when creating table - how to fix
January 19, 2025
Data - How to view the progress and status of a Dataverse CSV/Excel Import
January 15, 2025
Error - Diagnosing the error "Network error when using the Patch function" when saving data with a form
May 05, 2024
Dataverse - How to work around the error "multiple levels of many-to-one relationship expansion aren't supported"
April 05, 2024
Dataverse - The easiest way to modify Dataverse data outside of Dataverse and Power Apps
February 18, 2024
Dataverse - How to use a checkbox control a set a yes/no field in Dataverse
July 10, 2023
Dataverse - How to create Entity Relationship diagrams
January 22, 2023
Dataverse - How you can more quickly bulk update data using the SQL language
January 14, 2023
Dataverse - How to fix the bug in the 'Business Rules' editor that prevents numeric values from saving
January 05, 2023
Dataverse - What are the benefits, and how to create formula columns
July 20, 2022
Dataverse - How to sort the available choice items from a choice column
May 12, 2022
Error - Unable to modify Dataverse tables with error message, Language id should not be null
September 27, 2021
Dataverse - How to retrieve FetchXML or SQL for Dataverse views
July 13, 2021
Data - Why is Dataverse so fast?
June 15, 2021
Dataverse - How to filter Dataverse choice columns
June 07, 2021
Dataverse - How to switch to the classic designer when the option is not available
May 26, 2021
Licensing - What are Dataverse Restricted tables?
March 26, 2021
Media - How to save and work with microphone recordings
March 09, 2021
Dataverse - how to access tables from another environment
February 23, 2021
Dataverse - How to Patch the 5 most complex data types
January 19, 2021