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

Set variable based on 2 conditions

Hi. I found another post that was similar to what I want, but not exactly on target.

I want to set a variable based on 2 conditions. I have a list of Admins that I lookup so I can evaluate the logged in user to see if they are on the Admin list. If so, then certain fields are visible to them. This is the expression for that and it runs on the OnVisible setting of my form:

(Set(varUserAdmin,LookUp(colAdmin,'Admin Name'.Email=varCurrentUserEmail)))

Now I want to add a condition. I have added a Status column to my Admin list and the status is either Active or Inactive. I want to look up the admin on the list and only evaluate the admins with a Status of Active. What would that expression look like?

1 ACCEPTED SOLUTION

Accepted Solutions
Drrickryp
Super User
Super User

@Contractor86 

You could set your variable to 

Set(varUser,IsBlank(
                    LookUp(
                              colAdmin,'Admin Name'.Email=varCurrentUserEmail &&
                                        Status="Active"
                    )
             )
)

This will reduce to either true or false and you can use the variable as the Visible property of the controls in question.

View solution in original post

2 REPLIES 2
Drrickryp
Super User
Super User

@Contractor86 

You could set your variable to 

Set(varUser,IsBlank(
                    LookUp(
                              colAdmin,'Admin Name'.Email=varCurrentUserEmail &&
                                        Status="Active"
                    )
             )
)

This will reduce to either true or false and you can use the variable as the Visible property of the controls in question.

Contractor86
Frequent Visitor

I initially got an error because my Status field is a choice column. I just switched it to Text (easy enough to manage, it's basically a static list) and the error went away. Thank you!!

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (2,514)