cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
AraSaber12
Level 8

Office365user.MyProfile().department

Hi guys,

 

I created an app and in my app there is a gallery which is showing my employees. Imagine that I have 5 managers who will use my app. So there are 5 EmployerID, manager1 = EmployerdID 001, manager2 = EmployerdID2 etc.

 

Now I am using this formula in the Item property of my gallery: 

SortByColumns(Search(Filter('[dbo].[Employee]_1',Office365Users.MyProfile().Department=EmployerId),TextSearchBox1_1.Text,"EmployeeId","FirstName","Lastname"),"FirstName",If(SortDescending1,Descending,Ascending))

As you can see MyProfile().Departement = EmployerID. So every manager sees only his own employees which is belong to. 

 

But there is also a CEO which must have to see all the employees of the 5 managers. How can I achieve this? Or how can I achieve that for example manager 1 can see the employees of manager2 and3?

 

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Office365user.MyProfile().department

Hi @AraSaber12 ,

 

Please try below formula instead:

SortByColumns(Search(If(User().Email="CEOEmailAddress",Filter('[dbo].[Employee]_1',Or(Office365Users.MyProfile().Department="001",Office365Users.MyProfile().Department="002",Office365Users.MyProfile().Department="003",Office365Users.MyProfile().Department="004",Office365Users.MyProfile().Department="005")),Filter('[dbo].[Employee]_1',Office365Users.MyProfile().Department=EmployerId)),TextSearchBox1_1.Text,"EmployeeId","FirstName","Lastname"),"FirstName",If(SortDescending1,Descending,Ascending))

In this formula, you use the User().Email function to check if the current logged in user is CEO or not. If current user is CEO, then it will show all the data for the 5 EmployerID.

 

For more information about User function, please refer to:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-user

 

Regards,

Mona

Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
1 REPLY 1
Community Support Team
Community Support Team

Re: Office365user.MyProfile().department

Hi @AraSaber12 ,

 

Please try below formula instead:

SortByColumns(Search(If(User().Email="CEOEmailAddress",Filter('[dbo].[Employee]_1',Or(Office365Users.MyProfile().Department="001",Office365Users.MyProfile().Department="002",Office365Users.MyProfile().Department="003",Office365Users.MyProfile().Department="004",Office365Users.MyProfile().Department="005")),Filter('[dbo].[Employee]_1',Office365Users.MyProfile().Department=EmployerId)),TextSearchBox1_1.Text,"EmployeeId","FirstName","Lastname"),"FirstName",If(SortDescending1,Descending,Ascending))

In this formula, you use the User().Email function to check if the current logged in user is CEO or not. If current user is CEO, then it will show all the data for the 5 EmployerID.

 

For more information about User function, please refer to:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-user

 

Regards,

Mona

Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 121 members 4,532 guests
Please welcome our newest community members: