cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Spawn10
Helper III
Helper III

How do I combine multiple If statements?

I am building a PowerApps form on a SharePoint list. I have a field that I need to hide based on values from three dropdowns. Right now I have three different conditions that if either one of them is met, my control should be hidden/displayed. I have these three "If" statements that independently satisfy my three conditions....

If((DataCardValue16.Selected.Value="value1" || DataCardValue16.Selected.Value="value2" || DataCardValue16.Selected.Value="value3" || DataCardValue16.Selected.Value="value4"), true, false)


If(ddwnTestType.Selected.Value="Test14", false, true)


If(ddwnTestMethod.Selected.Value="method1" || ddwnTestMethod.Selected.Value="method2" || ddwnTestMethod.Selected.Value="method3" || ddwnTestMethod.Selected.Value="method4", true, false)

 

However when I put them together, I cannot get them to work. Here is one way I have tried to use all three in the "visible" property of the data card I am trying to hide. 

 

If((DataCardValue16.Selected.Value="value1" || DataCardValue16.Selected.Value="value2" || DataCardValue16.Selected.Value="value3" || DataCardValue16.Selected.Value="value4"), true, false) || If(ddwnTestType.Selected.Value="Test14", false, true) || If(ddwnTestMethod.Selected.Value="method1" || ddwnTestMethod.Selected.Value="method2" || ddwnTestMethod.Selected.Value="method3" || ddwnTestMethod.Selected.Value="method4", true, false) 

I can't get this to satisfy my combined condition. What would be the right syntax to get this to work?

Many thanks

1 REPLY 1
BCBuizer
Super User
Super User

Hi @Spawn10 ,

 

Since the conditions in the If() statements will return a boolean, there's no need to include the If() statements for a property that takes a boolean. In the below code I have removed the If()s, enclosed the three conditions in brackets and combined them with an || operator and inserted a ! operator to get the right output on the second condition:

 

 

(DataCardValue16.Selected.Value="value1" || DataCardValue16.Selected.Value="value2" || DataCardValue16.Selected.Value="value3" || DataCardValue16.Selected.Value="value4")

||

(!ddwnTestType.Selected.Value="Test14")

||

(ddwnTestMethod.Selected.Value="method1" || ddwnTestMethod.Selected.Value="method2" || ddwnTestMethod.Selected.Value="method3" || ddwnTestMethod.Selected.Value="method4")

 

 



Did you like my post? Please give it a thumbs up! Did I resolve your issue? Please click Accept as Solution to close the topic and so other members of the community can find solutions more easily.

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

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