hero_header_background
Power Apps : Filtering Data by the Current User.
Power Apps : Filtering Data by the Current User.
In the latest Power App that I am writing using Dataverse I wanted to filter data from a table on the currently logged in user. My programming back ground told me to find the logged in users GUID and use that as a filter within the app. This would have worked but there is a much simpler way to do this using Data Verse views.

Dataverse views enable us to define queries and filters in a way that is re-usable across multiple canvas apps and model driven apps. This is achieved without writing any code to create a filter.

1. Firstly lets look at the three records in the Leave Request table. You can see each record has a default field called 'Created By' and 'Owner' which is automatically populated.


DataverseTable2

2. Now the Canvas App is always accessible with a Microsoft 365 user and I want to filter the Leave Request table with the logged in user using a view. When inside the table settings select Views from the menu.


DataverseTable3


3. Inside the Views screen you will see current views created. Press the Add view button to create a new view.


DataverseTable4


4. Give the view a Name and Description.


DataverseTable5


5. Select the fields from the Leave Request table from the left and they will appear as columns. In my case I am selecting all fields.


DataverseTable6


6. Select Edit filters to filter the data for the view.


DataverseTable7


6. Select Add and Add row.


DataverseTable8


6. Now select the Owner row and change the condition to Equals current user. Press the OK button to accept.


DataverseTable9


7. You will notice the Filter by ... is Owner is current user . The rows in the view are only for the logged in user. Press the Save button and then the Publish to save the View and make it live..


DataverseTable10


8. Now back in the Canvas App you can see that the Leave Request table is displaying all of the records.


DataverseTable11


9. Change the Views option to the CurrentUser view that we created in Dataverse


DataverseTable11


10. Now that the view is set to CurrentUser the data table only shows data for the user that is logged in.


DataverseTable13

Key Advantages

  • A view is easy to create without writing any code.
  • Only the data selected in the view is loaded into the Canvas App improving page load performance.
  • The current user is automatically chosen by the user running the Canvas App.


One thought on “Power Apps : Filtering Data by the Current User.

Leave a Reply

Your email address will not be published. Required fields are marked *