cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PJS-Data-Admin
Helper II
Helper II

If Statement - Multiple Conditions

Hello All, 

 

I cannot find what is wrong with my multiple conditions if statement. The purpose is if the priority is a certain number, display a certain word.

 

Here is a sample of when it is working: 

 

if(equals(item()['priority'],10),'None','other')

 

Here is what I am trying to use:

 

 

if(equals(item()['priority'],0),'None', if(equals(item()['priority'],10),'Low',if(equals(item()['priority'],20),'Medium',if(equals(item()['priority'],30),'High','Error'))))

 

 

What is the issue/ what is the correct way to make this work?

 

Thank you!

2 ACCEPTED SOLUTIONS

Accepted Solutions
Paulie78
Super User
Super User

I didn't look what was wrong with your expression, but a suggestion, or a technique I like to use sometimes instead of nested ifs...

concat(
	if(equals(item()['priority'],0),'None',''),
	if(equals(item()['priority'],10),'Low',''),
	if(equals(item()['priority'],20),'Medium',''),
	if(equals(item()['priority'],30),'High','')
)

I find nested if statements quite messy.

 

View solution in original post

@PJS-Data-Admin 

Another technique that you can use when if statements get too messy is to use a Switch action

image.png

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

View solution in original post

6 REPLIES 6
ScottShearer
Super User
Super User

@PJS-Data-Admin 

Does your expression generate an error or does it just not give the correct outcome?

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott
PJS-Data-Admin
Helper II
Helper II

@ScottShearer 

It gives me an error message for the second formula above, the first one works perfectly - I believe I may need to add in an "or" statement, but I am not sure.

 

Error:

Unable to process template language expressions in action 'Compose' inputs at line '1' and column '11413': 'The template language expression 'if(equals(item()['priority'],0),'None',
if(equals(item()['priority'],10),'Low',
if(equals(item()['priority'],20),'Medium',
if(equals(item()['priority'],30),'High', 'Error'))))
' cannot be evaluated because property 'priority' cannot be selected. Please see https://aka.ms/logicexpressions for usage details.'.

Paulie78
Super User
Super User

I didn't look what was wrong with your expression, but a suggestion, or a technique I like to use sometimes instead of nested ifs...

concat(
	if(equals(item()['priority'],0),'None',''),
	if(equals(item()['priority'],10),'Low',''),
	if(equals(item()['priority'],20),'Medium',''),
	if(equals(item()['priority'],30),'High','')
)

I find nested if statements quite messy.

 

@Paulie78 Thank you! That appears to be working at the moment. 

@PJS-Data-Admin 

Another technique that you can use when if statements get too messy is to use a Switch action

image.png

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

@ScottShearer Thank you for this as well. This would certainly work in the majority of situations, but it was not my only piece that needed an outputted number to display as text.

 

Thank you for the example as well!

 

PJSDataAdmin_1-1632943776119.png

 

 

Helpful resources

Announcements
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.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (2,366)