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
Super User
Super User

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(...)

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
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (2,426)