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
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Top Kudoed Authors
Users online (1,991)