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

Why use || (or) instead && (And), to evaluate 2 values ?

Hi stupid question i know but i never understand why i need to use the operator || to evaluate my condition.

 

I have a buton and i want to display it, if the value from the component 1 and for the component 2 are true.

This is my formula - it's working

 

If(IsEmpty(Attachfiles.Attachments) || IsBlank(dpd_typologiedocs.Selected.Value);DisplayMode.Disabled)

 

So if there are no files in the component attachfiles and if the selected value is blank in the dropdown component, disable the displaymode.

At first, my logical says me to use And (&&) operator  and how it didn't work i use || and it works. 

 

I know it' s a stupid question. shame on me 

 

Thank for your clarification

 

1 ACCEPTED SOLUTION

Accepted Solutions
AmDev
Super User
Super User

Hi @Anonymous 

 

Not at all.. there's no such thing as a stupid question... or / and can be a bit of a minefield in certain situations.

 

Your instinct is correct and you need to use the And operator (i.e. to achieve 'true' And 'true'). If it didn't work when you used And, but it did work when you used Or, this means one of the two functions has not equated to true and needs to be corrected - but it appeared to work, as with Or all you need is one instance of 'true' (i.e. component 1 = true Or component 2 = true.

 

You can highlight each component in the formula bar to see which one it is that is showing false, when you expect true - and needs fixing.

 

Hope this helps

View solution in original post

3 REPLIES 3
AmDev
Super User
Super User

Hi @Anonymous 

 

Not at all.. there's no such thing as a stupid question... or / and can be a bit of a minefield in certain situations.

 

Your instinct is correct and you need to use the And operator (i.e. to achieve 'true' And 'true'). If it didn't work when you used And, but it did work when you used Or, this means one of the two functions has not equated to true and needs to be corrected - but it appeared to work, as with Or all you need is one instance of 'true' (i.e. component 1 = true Or component 2 = true.

 

You can highlight each component in the formula bar to see which one it is that is showing false, when you expect true - and needs fixing.

 

Hope this helps

Anonymous
Not applicable

Oh my god. I forgot that the if function evaluate if the conditions are true...

And in my case, if i add a file in the component attachfiles, the instance change to false. 

It seems logical now.

 

Thanks you for your explanation

AmDev
Super User
Super User

That great @Anonymous - glad you got sorted.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

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