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

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 I
Helper I

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

 

View solution in original post

@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

View solution in original post

@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
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Users online (2,083)