cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Post Prodigy
Post Prodigy

Count unselected radio buttons

Is there a way to count the amount of radio buttons unchecked in powerapps. In my gallery I have a radio button and there are about 50 buttons in gallery. I want to make sure the user hits all of them so when the radiobutton is checked I want a text label to decrease by one. Is this possible?

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

You could create a variable and set it to 0 in the screens OnVisible property then in the Radio OnChange property increase that variable by 1. Then you could use the variable in your label to display how many buttons have been click. 

 

Screen > OnVisible > Set(varRadioButtonSelectedCounter, 0)

Radio Control > OnChange >Set(varRadioButtonSelectedCounter, varRadioButtonSelectedCounter + 1)

 

If  you wanted to count backwards then you would initially set the variable to the starting number and then in the OnChange you would decrease the variable by one.



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

View solution in original post

7 REPLIES 7
Super User
Super User

You could create a variable and set it to 0 in the screens OnVisible property then in the Radio OnChange property increase that variable by 1. Then you could use the variable in your label to display how many buttons have been click. 

 

Screen > OnVisible > Set(varRadioButtonSelectedCounter, 0)

Radio Control > OnChange >Set(varRadioButtonSelectedCounter, varRadioButtonSelectedCounter + 1)

 

If  you wanted to count backwards then you would initially set the variable to the starting number and then in the OnChange you would decrease the variable by one.



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

View solution in original post

I noticed an error with this.. The problem is that when the person loads the app back up there will already be radio buttons selected. However the countdown number is still at 50. How can I get the number to stick when they reload the app? @Jeff_Thorpe 

Will all the all radio buttons be selected when the user loads it back up. If so, you can add some logic to the Visible to set the count variable depending on if this a new item or an existing item. Otherwise you will need to check every radio control to see if it is checked and adjust the count accordingly in the OnVisible property.



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

No when it is loaded back up not every button will be checked. So how do I implement this? In the label do I do something like If(Radio4.Selected, varRadioButtonSelectedCounter - 1) @Jeff_Thorpe 

If you are setting the starting variable in the OnVisible then update it to something like this:

Set(varRadioButtonSelectedCounter, 50);
If(Radio1.Selected, varRadioButtonSelectedCounter - 1);
If(Radio2.Selected, varRadioButtonSelectedCounter - 1);
If(Radio3.Selected, varRadioButtonSelectedCounter - 1);
--- rinse and repeat for all the radio buttons ---------
If(Radio50.Selected, varRadioButtonSelectedCounter - 1)

 



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

I only have one radio button it is in the gallery @Jeff_Thorpe 

I have a datasource that stores the persons submission to pull it back in called GUATResponses. I was thinking I could do something like counting them in the data source by email. Because with what you posted it will say 50 every time when the person opens the app even if they already have some selected from the previous submission @Jeff_Thorpe 

Helpful resources

Announcements
News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

Power Apps Community Call

Power Apps Community Call- January

Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

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