cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
al4629740
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

CurranD
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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (100,156)