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!
Solved! Go to Solution.
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.
Another technique that you can use when if statements get too messy is to use a Switch action
Does your expression generate an error or does it just not give the correct outcome?
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.'.
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.
Another technique that you can use when if statements get too messy is to use a Switch action
@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!
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Announcing a new way to share your feedback with the Power Automate Team.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
User | Count |
---|---|
70 | |
26 | |
16 | |
16 | |
15 |
User | Count |
---|---|
145 | |
45 | |
44 | |
33 | |
30 |