cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
hughrmarks
Level: Powered On

Adding variables

I have five labels and each is assigned a variable (vLabel1, vLabel2, vLabel3, vLabel4, and vLabel5) so that OnSelect, it toggles between true and false. I have it set so that the label is blue when the variable is false and red when it is true. All I need to do is to calculate the number of red labels versus the number of blue. I am just finding it hard to create an equation to count the number of labels that are true versus the number that are false. I need to be able to say Red = 2, Blue = 3, for example.
2 REPLIES 2
Super User
Super User

Re: Adding variables

Hi @hughrmarks

 

One way to do this is to add your variables to a table. In the example below, the Table function creates a table with 5 rows. The column name is 'Variable' and each row in the table corresponds to a vLabelX variable.

You can then call the CountIf function and specify a condition to return a row count.

The formula to return a count of red labels would look like this:

CountIf(
        Table({Variable:vLabel1},{Variable:vLabel2}, {Variable:vLabel3},{Variable:vLabel4},{Variable:vLabel5}),
        Variable=true
)


The formula to return a count of blue labels would look like this:

 

CountIf(
        Table({Variable:vLabel1},{Variable:vLabel2}, {Variable:vLabel3},{Variable:vLabel4},{Variable:vLabel5}),
        Variable=false
)
Community Support Team
Community Support Team

Re: Adding variables

Hi @hughrmarks,

 

I agree with @timl's thought almost, I have made a test on my side and my app's configuration as below:19.JPGAdd a Label control within your screen, the Text property of it set to following formula:

"Red="&CountIf(
        Table({Variable:vLabel1},{Variable:vLabel2}, {Variable:vLabel3},{Variable:vLabel4},{Variable:vLabel5}),
        Variable=true
)&", Blue="&CountIf(
        Table({Variable:vLabel1},{Variable:vLabel2}, {Variable:vLabel3},{Variable:vLabel4},{Variable:vLabel5}),
        Variable=false
)

Best regards,

Kris

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
firstImage

PowerApps Monthly Community Call!

Join us next Wednesday for our Demo Extravaganza, October 16, 2019 8am PDT.

firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 495 members 5,199 guests
Please welcome our newest community members: