Skip to main content
Community site session details

Community site session details

Session Id : 3fNc/ORWb582CAb6JQnbiH
Power Apps - Building Power Apps
Answered

Change value of radio button based on different radio button

Like (0) ShareShare
ReportReport
Posted on 27 Mar 2022 10:24:39 by 113

Hi,

 

I have to buttons which can't be both in the same time positive.

I want that if one is true the other will be false, and the opposite.

I have tried to set the default value with:

If (DataCardValue10=true,false,true)

 

But I receive error. 

Can someone help me please?

BTW I want to have the option for both to be false

(So the options are: 1. true, false 2. false, true 3. false, false)

moshem_0-1648376496735.png

 

Categories:
  • moshem Profile Picture
    113 on 28 Mar 2022 at 10:01:47
    Re: Change value of radio button based on different radio button

    @WarrenBelz Amazing! you are the best!

  • Verified answer
    WarrenBelz Profile Picture
    148,985 Most Valuable Professional on 28 Mar 2022 at 09:09:33
    Re: Change value of radio button based on different radio button

    Hi @moshem ,

    I had a chance to test it this time - try the following (replace all of the first one) - and they are toggles, not Radio buttons and note the change to OnSelect from OnChange

    Toggle1 OnSelect

    UpdateContext(
     {
     varToggle1: !Self.Value,
     varReset: false
     }
    );
    Reset(Toggle2)

    Toggle2 OnSelect

    UpdateContext(
     {
     varToggle2: !Self.Value,
     varReset: false
     }
    );
    Reset(Toggle1)

    Default of Toggle1

    If(
     varReset,
     false,
     varToggle2
    )

    Default of Toggle2

    If(
     varReset,
     false,
     varToggle1
    )

    Reset button and Screen OnVisible 

    UpdateContext(
     {
     varToggle1: false,
     varToggle2: false,
     varReset: true
     }
    );
    Reset(Toggle1);
    Reset(Toggle2)

    As below

    ResetToggle.gif

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

  • Himanshu_90677 Profile Picture
    416 on 28 Mar 2022 at 06:39:35
    Re: Change value of radio button based on different radio button

    create two variables (var_radio1, var_radio2)

    - set default value of radio button with these variables

    - use 'OnSelect' function in Radio1 and paste:
    Set(var_radio1,Self.Selected.Value);Set(var_radio2,If(Self.Selected.Value = "Yes","No","Yes"))

    - use 'OnSelect' function in Radio2 and paste:

    Set(var_radio2,Self.Selected.Value);Set(var_radio1,If(Self.Selected.Value = "Yes","No","Yes"))

  • moshem Profile Picture
    113 on 28 Mar 2022 at 06:18:59
    Re: Change value of radio button based on different radio button

    I have tried to uplaod a vid of the issue but it is an invalid file type here.

     

    I'll put screen shots:

    1) I have the code on screen:

    moshem_0-1648448169975.png

    2) Now one of them is always false:

    moshem_1-1648448210758.png

     

    3) Even when I press reset form it doesn't help:

    moshem_2-1648448244283.png

    4) I have tried to add a button with the code of both to false and it didn't help:

    moshem_3-1648448323611.png

     

  • WarrenBelz Profile Picture
    148,985 Most Valuable Professional on 28 Mar 2022 at 05:06:28
    Re: Change value of radio button based on different radio button

    @moshem ,

    Run the code I provided for Screen OnVisible - it will set both values to False

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

  • moshem Profile Picture
    113 on 28 Mar 2022 at 04:54:40
    Re: Change value of radio button based on different radio button

    @WarrenBelz hi,

    2/3 of the original question where answered

    I need to have 3 options:

    1) false true - you have answered

    2) true false - you have answerd

    3) false false - which you have made as the defualt but a user can't go back to this option if he by mistake chose one of the other options

  • WarrenBelz Profile Picture
    148,985 Most Valuable Professional on 28 Mar 2022 at 03:31:55
    Re: Change value of radio button based on different radio button

    @moshem ,

    Firstly, has your original question been solved? I also do not fully understand the logic of your current question.

  • moshem Profile Picture
    113 on 27 Mar 2022 at 13:15:28
    Re: Change value of radio button based on different radio button

    Thank you @WarrenBelz  Now it is the opposite, but I need to have the option for false and false, and now if the user once chose true for one of the options he can't make both false again (it is false only in the default view)

  • WarrenBelz Profile Picture
    148,985 Most Valuable Professional on 27 Mar 2022 at 10:35:22
    Re: Change value of radio button based on different radio button

    Hi @moshem ,

    Firstly, you cannot base them off each other or you will have a circular reference, so set a Variable on the OnChange of each = Radio 1

    UpdateContext({varRadio1: !Self.Value})

    and the other Radio 2

    UpdateContext({varRadio2: !Self.Value})

    and the Default of Radio1

    varRadio2

    and the Default of Radio2

    varRadio1

    make sure at Screen OnVisible to initiate the Variables

    UpdateContext(
     {
     varRadio1: false,
     varRadio2: false
     }
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 637 Most Valuable Professional

#2
stampcoin Profile Picture

stampcoin 570 Super User 2025 Season 2

#3
Power Apps 1919 Profile Picture

Power Apps 1919 473

Loading complete