cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
bfausti
Helper II
Helper II

Compare values from collection and toggle change

I need help with a known problem outlined here (https://powerusers.microsoft.com/t5/Building-Power-Apps/Onchange-event-often-triggers-when-screen-be...

 

I need to compare the value of a field called Targeted (true/false) in a local collection with the toggle control value when it is clicked/changed. I used the following but get an Incompatible types for comparison error (Table/Boolean):

if(colTargets.Targeted <> Self.Value,
 {Run action when the toggle really is clicked}
)
 
I am fairly new to PowerApps and am not sure how I can check if the toggle was changed so it doesn't fire when it is not clicked due to this bug. Very frustrating.




1 ACCEPTED SOLUTION

Accepted Solutions

So, you trying to see if the field yes is equal to true... You cant compare that..

You need to "convert" the yes to true and the no to false

So

 

If(gal_credits.Selected.Target = "yes" && Self.Value = true;

Notify(...)

View solution in original post

6 REPLIES 6
Nogueira1306
Community Champion
Community Champion

Hey! That is because you are giving the hole collection.

You need to choose the item of the collectino that you want to compare.

If you want the first: 

First(colTargets).Targeted 

 

If you Have them in a gallery:

 

Gallery.Selected.Targeted 

Thanks for the information.

However, I am getting a new comparison issue now, see below:

 

bfausti_0-1628757484028.png

 

Any ideas?

Hey. 

Is your field Targeted a combobox or a dropdown?

Hi @Nogueira1306, the control used is a toggle and the field is a yes/no:

bfausti_0-1628757980282.png

 

So, you trying to see if the field yes is equal to true... You cant compare that..

You need to "convert" the yes to true and the no to false

So

 

If(gal_credits.Selected.Target = "yes" && Self.Value = true;

Notify(...)

View solution in original post

Thanks that worked! Thanks allot 🙂


Final code was:

If(Text(gal_credits.Selected.Targeted) = "Yes" && Text(Self.Value) = "true",
Notify("Targeted Clicked");
);

 

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 (1,814)