web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Change value of radio ...
Power Apps
Unanswered

Change value of radio button based on different radio button

(0) ShareShare
ReportReport
Posted on 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:
I have the same question (0)
  • WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    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

     

  • moshem Profile Picture
    113 on at

    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
    153,026 Most Valuable Professional on at

    @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 at

    @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
    153,026 Most Valuable Professional on at

    @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 at

    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

     

  • Himanshu_90677 Profile Picture
    416 on at

    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"))

  • Verified answer
    WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    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

  • moshem Profile Picture
    113 on at

    @WarrenBelz Amazing! you are the best!

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard