cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ALP1
Super User
Super User

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 @ALP1 

 

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 @ALP1 

 

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

ALP1
Super User
Super User

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 @ALP1 - glad you got sorted.

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

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