cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

If Statement with multiple conditions

Hi everyone

 

I think this is a simple issue but struggling with If statements in a PowerApp with SharePoint datasource.  I have the following fields:

Q1 Question

Q1 Answer

 

Q1 Question is a Choice field with choices of 2,10, 20, 5000.

Q1 Answer is a text field.

I need to set the Field Q1 Answer to a value based on the choice made in Q1 Question.

 

I have read a bunch of articles on this and it is not totally clear how the field name should be set.  I have tried a number of variations of the If statement but cannot get it to work, I constantly get the following error:

Expected Operator. We expect an Operator such as +,*, or & at this point in the formula.

 

My current attempt is as follows:

 

=if(Q1 Question.value = 2,"2", Q1 Question.value = 10,"3", Q1 Question.value = 20,"5", Q1 Question.value = 5000,"10")

 

I have placed this in the Text property of the Q1 Answer field but think it would be better if I could set the Q1 Answer field when the Q1 Question field changes, so I presume I will need to set this on some property of Q1 Question?

 

SO my question is 2 parts:  How do I correctly write the If statement and what is the best way to do this - on Q1 answer or on Q1 Question?

 

Thanks for the help!

4 REPLIES 4
Highlighted
Super User III
Super User III

Re: If Statement with multiple conditions

You may not need if for this. Insert a dropdown1 and set the Items of the dropdown1 with the List: Choices( List.'Q1 Question' )

Then in the textbox for the answer put: dropdown1.Selected.Value

 

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Highlighted
Frequent Visitor

Re: If Statement with multiple conditions

Thanks @eka24 , I understand most of your answer but not really sure what to do here:

 

set the Items of the dropdown1 with the List: Choices( List.'Q1 Question' )

 

I am rather new to PowerApps to still trying to get to grips with everything - sorry if I ask annoying obvious things!

Highlighted
Super User III
Super User III

Re: If Statement with multiple conditions

You are encouraged to ask all the questions.

In 2nd attached change the dropdown name to the actual name of your dropdown.

See attached:

Highlighted
Frequent Visitor

Re: If Statement with multiple conditions

Thank you, I will give this a bash in the morning.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (6,393)