cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Check if every label in a gallery equals a value

Hello,

 

In an app im doing i wanted to set the display mode of a button to edit  if all values of a label inside a gallery are 8, else it would be disabled.

 

I tried something like "If(ForAll(Gallery.AllItems,Value(Label.Text)).Value = 8,Edit,Disabled)" but not working and can´t figure out how to go around this issue.

 

Thank you very much for your help!

AVasques

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@Anonymous 

 

Consider trying this formula instead:

If(
   CountIf(Gallery.AllItems, Value(Label.Text)=8) = CountRows(Gallery.AllItems),
   Edit,
   Disabled
)

 

That should give you what you are looking for.

 

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!

View solution in original post

4 REPLIES 4
RandyHayes
Super User
Super User

@Anonymous 

 

Consider trying this formula instead:

If(
   CountIf(Gallery.AllItems, Value(Label.Text)=8) = CountRows(Gallery.AllItems),
   Edit,
   Disabled
)

 

That should give you what you are looking for.

 

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!

View solution in original post

v-qiaqi-msft
Community Support
Community Support

Hi@AVasques,

Based on the issue that you mentioned, do you want to change the DisplayMode if values in all the Labels are "8"?

Could you please share more about your scenario, is there a column combined with the values form Labels within your data source?

What's more, what is your data source, and which type is your column combined with the values form Labels?

The formula you provided just identify if the single Label value is "8", you should use CountRows if you want to check all the Labels' values.

If you just to change the DisplayMode of the Button depends on Label value,  @RandyHayes  provides the correct direction. However, I am not sure about the data type of the column combined with the Labels, so I have made a test on my side which I use SharePoint list as my data source. I have a Text column to fill the Labels.

Please modify your formula as below.

 

 

If(
   CountIf(Gallery1.AllItems, Label4.Text="PR") = CountRows(Gallery1.AllItems),
   Edit,
   Disabled
)

 

 

002.png

Best Regards,

Qi

 

Best Regards,
Qi

@v-qiaqi-msft 

The datasource is quite irrelevant in this case as the formula only considers the Text of the label in the count.  Even if the datasource was an integer (i.e. the label text property was set to ThisItem.AnIntegerColumn) the conversion to text has already been done.  The formula provided would not "convert it back to an integer" in any way.  

_____________________________________________________________________________________
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 been looking for similar solution as the poster for a while, thanks so much for this, seems so simple now !

 

Regards

Ryan

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,283)