cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Regular Visitor

Filter datasource by user

We have several difference users in Office 365.  When each access one particular table in the data source, we want them to have access only to data that relates to them and not view other information that does not concern them.  If we have a column that specifies which user that record belongs to, is there a way to filter that information to ony that user once they log into their powerapp?  Basically, is there a way for their username/login to be used to filter the data that they are able to view?

1 ACCEPTED SOLUTION

Accepted Solutions

User() pulls up the current user who's logged in, then the .FullName would fetch the full name for that user (Firstname Surname).

 

So Jane Doe with the email jd@email.com:

  • User().FullName - "Jane Doe"
  • User().Email - "jd@email.com"

 

EDIT: Here's the Microsoft Docs page for this: https://docs.microsoft.com/en-us/powerapps/functions/function-user

View solution in original post

8 REPLIES 8
Anonymous
Not applicable

my bad wrong thread

Advocate I
Advocate I

If you have a field the same as the users 'Full Name' you should be able to filter by User().FullName or even User().Email

 

Never tried it but should work?

 

E.g.

 

Filter(Collection, OwnerField = User().FullName)

Is User().Email a system control that pulls up whomever is currently logged in?

User() pulls up the current user who's logged in, then the .FullName would fetch the full name for that user (Firstname Surname).

 

So Jane Doe with the email jd@email.com:

  • User().FullName - "Jane Doe"
  • User().Email - "jd@email.com"

 

EDIT: Here's the Microsoft Docs page for this: https://docs.microsoft.com/en-us/powerapps/functions/function-user

View solution in original post

Very cool.  In the profile in Office 365, there is a section for Department and Office.  Could I filter the data they view by those variables also?

Very cool.  In the profile in Office 365, there is a section for Department and Office.  Could I filter the data they view by those variables also?

Nope, not with the User() command as that only fetches data that Powerapps needs.

 

If you wanted to filter by other sections of Office 365 you'd have to add a connection to Office365 in your app.

 

Can find an overview of doing that here: https://powerapps.microsoft.com/uk-ua/tutorials/connection-office365-users/

 

You can then use any of the following:

  • Office365Users.MyProfile().Department
  • Office365Users.MyProfile().DisplayName
  • Office365Users.MyProfile().GivenName
  • Office365Users.MyProfile().Id
  • Office365Users.MyProfile().JobTitle
  • Office365Users.MyProfile().Mail
  • Office365Users.MyProfile().MailNickname
  • Office365Users.MyProfile().Surname
  • Office365Users.MyProfile().TelephoneNumber
  • Office365Users.MyProfile().UserPrincipalName
  • Office365Users.MyProfile().AccountEnabled

Again not tested filtering based off these values but theoretically it should work 🙂

 

Anonymous
Not applicable

Hi I have tried this and it makes sense and works thank you. I would like to take this one stage further though and...

 

My issue is that I am trying to filter an existing data list by a column called "Country".

 

Issue 1

On the edit screen where the in country person adds a new line of data and completes the new data input by pulling down choice fields, I cannot get the pull down for "Country" to only show their Country it shows them all countries in the list. 

 

I have a list of countries and a list of users assigned to the countries so i can build a separate list to contain these if required to do a look up to or link back to?  

 

Issue 2

My master data list is built and linked to a PowerApp and everything works as it should apart form when I try and apply a filter to only show the user their Country data - I either get all the data or nothing at all.

 

Can you help on this at all? I can provide any details required as I have been trying to do this for opver a week.

 

Helpful resources

Announcements
News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

Power Apps Community Call

Power Apps Community Call- January

Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

Top Solution Authors
Top Kudoed Authors
Users online (11,714)