cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
pedromoreno
Level: Powered On

IF and ELSE Function to rotate true and false

Hi,

 

Lets say i have got a button that every time it does thefollowing:

If A is enabled, disbale A and Enable B and If B is enabled, disbale B and Enable A

 

This is what i have in Button Action:

If(EnabledA;true) - UpdateContext({EnabledA: false}) & UpdateContext({EnabledB: true}) - (false) - UpdateContext({EnabledA: true}) & UpdateContext({EnabledB: false})

 

It seems just to do the last part: A Ends up enabled

If i remove the part in front of "-"  B stays enabled

 

I'm doing somethng wroug but i cant find the way to aply else or else if... something ike that...

 

Thank you in advance

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PowerApps Staff CarlosFigueira
PowerApps Staff

Re: IF and ELSE Function to rotate true and false

I think I understand :). You can update multiple variables in the same UpdateContext call, and if you use the If function, you can perform an action in the case of the condition being true and another one in the case the condition is false. I think this should do what you need:

If(
    EnabledA;
    UpdateContext({EnabledA: false; EnabledB: true};
    UpdateContext({EnabledA: true; EnabledB: false})
)

View solution in original post

3 REPLIES 3
PowerApps Staff CarlosFigueira
PowerApps Staff

Re: IF and ELSE Function to rotate true and false

You can use a single variable, and use the Not function (or the ! operator), to have opposite values for it. Here is one way you can implement that:

ButtonA.Disabled: !EnabledA
ButtonA.OnSelect: UpdateContext({ EnabledA: !EnabledA })

ButtonB.Disabled: EnabledA
ButtonB.OnSelect: UpdateContext({ EnabledA: !EnabledA })

When any button is clicked, the value of the EnabledA variable is toggled between true and false.

 

Hope this helps!

pedromoreno
Level: Powered On

Re: IF and ELSE Function to rotate true and false

I only have one button, and i want that button to control the 2 variables becouse they are used for other stuff also.

What you have just showed me should work very fine for other stuff that i can make simple.. thank you 🙂

 

But i need to control that one with the IF statment.. any ideas 🙂

PowerApps Staff CarlosFigueira
PowerApps Staff

Re: IF and ELSE Function to rotate true and false

I think I understand :). You can update multiple variables in the same UpdateContext call, and if you use the If function, you can perform an action in the case of the condition being true and another one in the case the condition is false. I think this should do what you need:

If(
    EnabledA;
    UpdateContext({EnabledA: false; EnabledB: true};
    UpdateContext({EnabledA: true; EnabledB: false})
)

View solution in original post

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

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

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (6,063)