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 / Counting how many yes ...
Power Apps
Unanswered

Counting how many yes in a radio button.

(0) ShareShare
ReportReport
Posted on by 16

Hi ,

I have a app I am building. In this app it ask's about 15 questions with radio buttons that have a yes or no answer. I need to write a if statement  that counts how many yes's there are and if it more than 2 it changes the screen color.  With the help from user @mdevaney  I implemented the following code. 

 

If((If(Radio1_26.SelectedText.OptionText ="No",2,0)+If(Radio1_2.SelectedText.OptionText ="Yes",1,0)+If(Radio1_3.SelectedText.OptionText ="Yes",1,0)+If(Radio1_4.SelectedText.OptionText ="Yes",1,0)+If(Radio1_5.SelectedText.OptionText ="Yes",1,0)+If(Radio1_6.SelectedText.OptionText ="Yes",1,0)+If(Radio1_7.SelectedText.OptionText ="Yes",1,0)+If(Radio1_8.SelectedText.OptionText ="Yes",1,0)+If(Radio1_9.SelectedText.OptionText ="Yes",1,0)+If(Radio1_10.SelectedText.OptionText ="Yes",1,0)+If(Radio1_14.SelectedText.OptionText ="Yes",1,0)+If(Radio1_15.SelectedText.OptionText ="Yes",1,0)+If(Radio1_16.SelectedText.OptionText ="Yes",1,0))>1,Green,Red)

 

 

Un fortunately no mater how many yes's or no's are selected it always stays green. I'm not sure what i have done wrong. any help would be greatly appreciated. 

Categories:
I have the same question (0)
  • Verified answer
    RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @dshawSLDC 

    You might consider the following formula as a replacement:

    If( 
     CountRows(
     Filter(
     Split(
     Radio1_26.Selected.OptionText & ";" &
     Radio1_2.Selected.OptionText & ";" &
     Radio1_3.Selected.OptionText & ";" &
     Radio1_4.Selected.OptionText & ";" &
     Radio1_5.Selected.OptionText & ";" &
     Radio1_6.Selected.OptionText & ";" &
     Radio1_7.Selected.OptionText & ";" &
     Radio1_8.Selected.OptionText & ";" &
     Radio1_9.Selected.OptionText & ";" &
     Radio1_10.Selected.OptionText & ";" &
     Radio1_14.Selected.OptionText & ";" &
     Radio1_15.Selected.OptionText & ";" &
     Radio1_16.Selected.OptionText,
     ";" 
     ),
     Result="Yes"
     )
     ) > 1, Green,
     Red
    )

     

    I noticed that you had what appeared to be the opposite logic on the Radio1_26 control.  Not sure the significance of that.

    But, if you want to count the Yes's, the above formula should do it.

    If you need a weighted system of counting then I like @mdevaney's formula for the assignment of numeric values.

    I also assume that your Radio control Items property has an "OptionText" field in it.

    Avoid using the SelectedText property of the controls that have them as they have been deprecated. 

     

    I hope this is helpful for you.

  • dshawSLDC Profile Picture
    16 on at

    Thanks, once I changed to selected instead of selectedtext it worked.

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