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

IF statement with two Variables

Hello,

         Could someone help me and tell me whats missing from my code.

 

I have 2 variables that are tied to the onVisible property of several elements. But i am having a problem getting the second variable to trigger.

 

I have a button that when clicked should set both variables to false even if one of them already is set to false. But what happens is that the first variable gets set to false and the second stays at true.

 

If(
   var1,false,
   var2,false
)

This code is set in the OnSelect property of a button. The desired outcome is to evaluate if the variable is true then set it to false. I was trying to see about using a elseIf function but from what i read this doesnt exisit in powerapps.

I.e 

 

If var1=true,updatecontext({var1:false})

elseIf

   var2=true,updatecontect({var2:false});

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: IF statement with two Variables

@stephenJames 

After reading your post it is my understanding that both variables should be changed to False no matter what their current state is.  If that's the case, I don't believe there is any need for an IF statement.

 

Use this if var1 and var2 are global variables

Set(var1,false);Set(var2,false)

 

Or this if var1 and var2 are context variables

Updatecontext({var1:false, var2, false}

 

---
Please click "Accept as Solution" if my response helped to solve your issue so that others may find it more quickly. If your thought the post was helpful please give it a "Thumbs Up."

View solution in original post

2 REPLIES 2
Super User
Super User

Re: IF statement with two Variables

@stephenJames 

After reading your post it is my understanding that both variables should be changed to False no matter what their current state is.  If that's the case, I don't believe there is any need for an IF statement.

 

Use this if var1 and var2 are global variables

Set(var1,false);Set(var2,false)

 

Or this if var1 and var2 are context variables

Updatecontext({var1:false, var2, false}

 

---
Please click "Accept as Solution" if my response helped to solve your issue so that others may find it more quickly. If your thought the post was helpful please give it a "Thumbs Up."

View solution in original post

Highlighted
stephenJames
Level 8

Re: IF statement with two Variables

@mdevaney Thanks for your response. that worked a treat. 

I had originally tried your suggestion and it didnt work but i did for some reason have an or statement in it

Set(var1,false) || Set(var2,false)

Helpful resources

Announcements
Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

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

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Microsoft Business Applications Virtual Launch

Join us for the Microsoft Business Applications Virtual Launch Event on Thursday, April 2, 2020, at 8:00 AM PST.

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (10,253)