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

Button Visible based on 2 columns of SP List

Hello all I have been searching and I am stumped.  

 

++Edit++ added some posts with more context.  Basically I need a button visible if their email is in the SP List and a specific value is in a multi select field of their SPList entry.

 

I have a Power App with buttons that are visible if the logged in user exists in a SP list using the following works where DataSource is my SP List with a column of Email

 

Visible = If(User().Email in 'DataSource'.Email, true)

 

That same SP List has a Department Column which is a multiple choice and I would like to show buttons only to users that need them.

 

For instance a button called "Update Tax" should only be visible to a user whose email is in the SP List Email column and Tax is one of the selected values in the Department column

1 ACCEPTED SOLUTION

Accepted Solutions
tjpreissig
Frequent Visitor

I was able to solve this with the following

 

If(
CountIf('SPList', User().Email in Email && "Tax" in Department.Value),
true,
false
)

 

Not sure if that is the best way but it seems to work.

View solution in original post

9 REPLIES 9
Drrickryp
Super User
Super User

@tjpreissig 

Visible property of first button described above:  !IsBlank(Lookup(spList, Email=User().Email))

Visible Property of "Update Tax" button:  

 

!IsBlank(LookUp(spList, Email=User().Email)) && 
!IsBlank(LookUp(splist, "Tax" in Department.Value))

If(... not needed since the statement above reduces to true or false

 

 

That worked thank you!  I do get a warning of "Delegation Warning. The highlighted part of this formula might not work correctly on large data sets."  I assume with the SP List only having 20 or less entries I should be ok?

Drrickryp
Super User
Super User

@tjpreissig 

You will always get a delegation warning when the "in" operator is used in SharePoint. As long as your list is <500 items you can ignore it. 

Sorry to bother again, this kind of works.  What is going on is if Anyone on the list has Tax assigned it is visible for everyone.  It needs to be if their email is on the list and tax is there for their name

Drrickryp
Super User
Super User

@tjpreissig 

Please post the visible property of the 2nd button. If you used my formula it shouldn't be possible as both conditions need to be satisfied for the button to be visible. Test the second condition by putting a datatable on a screen with 

Filter(splist, "Tax" in Department.Value) in its items property and see what you get.

!IsBlank(LookUp('SPLIST', Email=User().Email)) &&
!IsBlank(LookUp('SPLIST', "Tax" in Department.Value))

 

The problem if the SPLIST has me and you in it but only I have Tax as a value in the Department Column then the button will be visible for both of us if I understand it right the visible property is just looking to see if "Tax" is present not necessarily for the combination of email and Tax

 

 

There are 6 buttons with corresponding departments in the multi-choice column of the SPList the desired effect would be you have 3 options selected in your department column then you get those 3 buttons while I will get only the buttons I have selected there.  Right now the Visible command is the same for all 6 only with "Tax" changed to the correct option.  This works fine for a single user however as soon as a second user is added both users get buttons for all users.  I hope I am explaining it correctly

tjpreissig_0-1661452394752.png

here is my SP List User 1 should only have the Access Button, User 2 should have Access and Org, while User 3 should have them all.  Currently all users have all buttons because all the department exists on user 3

tjpreissig
Frequent Visitor

I was able to solve this with the following

 

If(
CountIf('SPList', User().Email in Email && "Tax" in Department.Value),
true,
false
)

 

Not sure if that is the best way but it seems to work.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,378)