cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
illmatic
Helper IV
Helper IV

Toggling form visibility based on radio button value

I have a canvas app with multiple screens.  Screen 1 has radio button choices [Choice A, Choice B, Choice C].  Screen 2 has corresponding forms [Form A, Form B, Form C].  When a user selects a choice, they are navigated to Screen 2 which displays the corresponding form.  [IE, User selects Choice A on first screen, and navigates to screen 2 showing Form A only].   The rest of the forms are hidden.   I am having trouble toggling visibility based on the radio button's selected value.

 

I have set a global variable on the app:  Set(varProjectType, Radio1.Selected.Value)   to store the users choice.

Then, on each of the forms, I have set the Visible property to:   If(varProjectType = "Choice", true, false).  My assumption is that it checks if the user's choice is equal to the string, then set the Visible property to true if it's true, or false if it's not.   This would toggle the visibility accordingly.   Instead, even when the selected Choice equals the text, the form is not visble.


I can't figure out what I'm doing wrong...    I could set the Visible property to show If(Radio1.Selected.Value="Choice A") on the form, but this would cause performance degradation so I'm trying to toggle in the most efficient way.  

 

Please advise.  Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions

@illmatic 

I would pretty much ignore it. 

We use it all the time this way and have Never seen any degradation in performance or other impact.

 

Consider what you are doing...adding a formula to set a variable. 

1) The overhead of the app having another object.

2) The cycles to set the variable.

3) The maintainability to the designer of keeping the variable current whenever your Radio1 changes - your variable will not update itself - you will need to put the formula in to update your variable if the control changes

 

PLUS...and this is the biggest point, when you set your variable each time, you are referring to Radio1.Selected.Value.  So if your Form refers to it as well, what is the difference?  I would say it is the difference of 1 reference. 

With a variable, again you will have to maintain it and keep it current with the control value.  That means many references to the control over and over.  Then, your Form Visible property will need to reference your variable.

 

I've never brought this point to a head, but I strongly contest that there is any performance degradation as I have never (in hundreds of apps) experienced a millisecond of degradation.  And again, we use this method in almost ALL the apps.  They become much easier to maintain when you ditch the variables.

 

Anyway...I could go on and on, but I think you got the point.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

5 REPLIES 5
RandyHayes
Super User
Super User

@illmatic 

Why do you feel there is a performance degradation? 

That would be my recommended method.  Setting a variable for something that you already have a variable for (the control property) is redundant and you would need to constantly keep that updated in your own formulas.

 

So, I would recommend that in your Form Visible property that you have the following formula:

Radio1.Selected.Value="Choice A"

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@RandyHayes 

When going through the app to check for errors etc, the system message noted that the first method [the one you suggested] would cause degradation in performance since I was referencing data controls on a different screen and suggested to use variables, update context, or a collection.

@illmatic 

I would pretty much ignore it. 

We use it all the time this way and have Never seen any degradation in performance or other impact.

 

Consider what you are doing...adding a formula to set a variable. 

1) The overhead of the app having another object.

2) The cycles to set the variable.

3) The maintainability to the designer of keeping the variable current whenever your Radio1 changes - your variable will not update itself - you will need to put the formula in to update your variable if the control changes

 

PLUS...and this is the biggest point, when you set your variable each time, you are referring to Radio1.Selected.Value.  So if your Form refers to it as well, what is the difference?  I would say it is the difference of 1 reference. 

With a variable, again you will have to maintain it and keep it current with the control value.  That means many references to the control over and over.  Then, your Form Visible property will need to reference your variable.

 

I've never brought this point to a head, but I strongly contest that there is any performance degradation as I have never (in hundreds of apps) experienced a millisecond of degradation.  And again, we use this method in almost ALL the apps.  They become much easier to maintain when you ditch the variables.

 

Anyway...I could go on and on, but I think you got the point.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

Lol, still I do appreciate your long winded reply all the same ;).  Less work for me!  Thanks for your insights 🙂

@illmatic 

Yeah, I am busy on an app and was procrastinating by going on and on.  😉

Trust me though, once you get away from "variable management" in your app, the easier PowerApps becomes.

 

I am glad you found it helpful.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (976)