cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
RoScha
Helper V
Helper V

Count how many toggle buttons are on yes

Hello community,

this time I have the following topic:

 

On the screen below you will see a Form with toggle buttons.

RoScha_0-1607505620014.png

If the toggle buttons have been set to "yes", I would like to count them straight away, in the blue label. Because I want to control the visibility of the save button with it.

 

Means: if no toggle button was set to "yes", the blue label shows "zero" and if a toggle button is set to "yes", this must then happen as a formula: 0 = 0 + 1 or X=X+1

If the toggle button is set from "yes" to "no", the formula is of course X = X-1 until "ZERO" is reached again at some point.

I hope you understand what I mean.


Now the exciting question is: how do I get that?

 

Thank you for your help.

 

Best regards

RoScha

1 ACCEPTED SOLUTION

Accepted Solutions
GarethPrisk
Resident Rockstar
Resident Rockstar

You can easily count True toggles, since it produces a False (0) or True (1) value. PowerApps is able to use both the boolean/integer value, contextually.

Set your Blue label (for counting):

Sum(
    Toggle1.Value,
    Toggle2.Value,
    Toggle3.Value,
    Toggle4.Value
)

It may require some fine-tuning since you're using a Form, and the Toggles may produce a non-standard value (depending on their source), but this should work.

 

You mention this may be simply to control the visibility of a Save button. You don't need the count/label above, unless you want to show that to users. Instead, set the Visible property of your Save button to

Or(
    Toggle1.Value,
    Toggle2.Value,
    Toggle1.Value,
    Toggle2.Value
)

This will make it visible, if any Toggle is true.

View solution in original post

2 REPLIES 2
GarethPrisk
Resident Rockstar
Resident Rockstar

You can easily count True toggles, since it produces a False (0) or True (1) value. PowerApps is able to use both the boolean/integer value, contextually.

Set your Blue label (for counting):

Sum(
    Toggle1.Value,
    Toggle2.Value,
    Toggle3.Value,
    Toggle4.Value
)

It may require some fine-tuning since you're using a Form, and the Toggles may produce a non-standard value (depending on their source), but this should work.

 

You mention this may be simply to control the visibility of a Save button. You don't need the count/label above, unless you want to show that to users. Instead, set the Visible property of your Save button to

Or(
    Toggle1.Value,
    Toggle2.Value,
    Toggle1.Value,
    Toggle2.Value
)

This will make it visible, if any Toggle is true.

Hello @GarethPrisk 

I am always amazed at how easy it is to make solutions and how I once again thought too complicated.

Many thanks.

 

Best regards

RoScha

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (1,289)