Get the difference between two dates EASY
image-1
![]()
jcook127001
![]()
![]()
![]()
![]()
![]()
![]()
![]()
image-1
![]()
jcook127001
![]()
![]()
![]()
![]()
![]()
![]()
![]()
“I’d like to use the if(…) expression but I don’t know how to create the condition, is there some trick in the Power Automate designer?”
Recently I published an article on replacing the ‘Condition’ actions with if(…) expressions to simplify a flow. Instead of a bunch of conditions and repeating actions you can have just a single action with if(…) expressions. But creating the right condition inside if(…) is a bit more complicated than using the standard action. How do you “rewrite” the condition? What should you “type in” as the first parameter of the expression?
As with the trigger conditions, you can use a small trick and let the designer create the condition for you. Add the ‘Filter array’ action into your flow and recreate the condition you want to replace with the if(…) expression.

Click on ‘Edit in advanced mode’ to transform the condition inside ‘Filter array’ into text.

Remove the @ at the beginning and take the rest, that’s the condition to use as the first parameter in if(…).

In this example to check whether a value is less than 3 it’d look as below.
if(less(outputs('Compose_-_Value'), 3), <ifTrue>, <ifFalse>)
Repeat the same process for all the ‘Condition’ actions you want to replace and build the whole expression step by step.
It might be a bit confusing when trying to replace the Power Automate ‘Condition’ with the if(…) expression, but it’s not that hard. If you use the workaround with the ‘Filter array’ action you don’t need to write the whole condition manually. Recreate the condition 1:1 in that action, switch to the text mode, remove the @, and the condition is ready. You can even combine multiple conditions together using this approach, just build it slowly, condition after condition.
Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?
I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.
All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.
Zero spam, unsubscribe anytime.
The post Create easily the condition for Power Automate if(…) expression appeared first on Let's POWER Automate.
“I feel that I’ve got too many conditions to handle basic stuff, can I somehow reduce/replace them to simplify my Power Automate flow?”
Conditions, one of the key building blocks in Power Automate. A simple decision: if “something” is true, do this, otherwise do that. But often it’s not that simple and if a condition is false it leads to another condition, another true or false. And the more potential options there’re, the more conditions you’ll need.
Is that really necessary? Isn’t there an easier way than a tree of conditions?
The Power Automate if(…) expression is the equivalent of the ‘Condition’ action. Instead of adding the action and then deciding e.g. on a value for some field, you can use the if(…) expression to get the correct value right away.
The basic if(…) expression was already explained in the date-formatting article and looks as below.
if(<condition>, <ifConditionIsTrue>, <ifConditionIsFalse>)
What you maybe didn’t know is that you combine them inside each other. Evaluate the first condition, and if it’s false try another evaluation.
if(<condition>,
<ifConditionIsTrue>,
if(<condition2>,
<ifCondition2IsTrue>,
<ifCondition2IsFalse>)
)
And it can go on an on, as many ifs as you need. But how do you build such expression?
Let’s take an example, a flow where you translate a number into more generic value. If the number is less than 3 the value is LOW, for 3 or 4 it’s MID, and if it’s 5 or more it’s HIGH. When using the ‘Condition’ actions it’ll look as below.

To turn it into a single expression with if(…) start from the bottom. The last condition evaluates whether the value is less than 5.
if(less(outputs('Compose_-_Value'), 5),<ifTrue>,<ifFalse>)
You can use the trick with the ‘Filter array’ action if you’re not sure how to write such condition.
If it’s true, use the value MID, otherwise use the value HIGH.
if(less(outputs('Compose_-_Value'), 5), 'MID', 'HIGH')
That was the last condition, now let’s go one step higher, to the previous condition. The flow will reach the 2nd condition only if the first condition is false.
if(<condition>, <ifTrue>, if(less(outputs('Compose_-_Value'), 5), 'MID', 'HIGH'))
The first condition should evaluate whether the value is less than 3.
if(less(outputs('Compose_-_Value'), 3),
<ifTrue>,
if(less(outputs('Compose_-_Value'), 5),
'MID',
'HIGH'
)
)
And if it’s true, it should use the value LOW.
if(less(outputs('Compose_-_Value'), 3),
'LOW',
if(less(outputs('Compose_-_Value'), 5),
'MID',
'HIGH'
)
)
Since there’re no other conditions in the flow, that’s it. A single expression that’ll get the value without branching the flow.

Whenever you start stacking conditions in your Power Automate flow, you should reconsider whether they are needed, or if you can replace them and simplify the flow. Start from the last condition, convert it into if(…) expression, and keep adding the other conditions around it. At the end it can be a single expression that can replace a whole bunch of the ‘Condition’ actions.
It’s another concept complementing the configuration lists that’ll help you build more efficient and easier to manage flows.
Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?
I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.
All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.
Zero spam, unsubscribe anytime.
The post Replace multiple conditions with single Power Automate expression appeared first on Let's POWER Automate.
“I’d like to pick a specific item from an array, what’s the best approach to navigate in there using Power Automate?”
Arrays are a key part of almost every Power Automate flow. It can be an array of SharePoint items or Dataverse rows, array with users inside multiple people picker field, or any other array created by splitting a string. Often you want to process all the items, but in some situations you need just one specific value. How do you navigate in an array? How do you get the value on the first place, last place, or anywhere in between?
If you need the first or last item, you can use an expression. This is very often used to avoid loops in a flow – if there’s only one item you don’t need a loop, you can just take the first one and use it directly.
The expression to get the first item is first(…).
first(<array>)
With an example array [“a”, “b”, “c”] the first(…) expression will return “a”.

The second expression, this one to get the last item is last(…).
last(<array>)
With an example array [“a”, “b”, “c”] the last(…) expression will return “c”.

If you’re not interested in the first or last item, you can use also indexes in the array for navigation as explained in the JSON navigation article. Adding an index in square brackets will get you the specific item. It starts from 0 (first item) and goes up to length-1 (last item).
<array>[<index>]
As an example, to get the 2nd item use index 1.

It gets a lot more complicated if you don’t know the position. If you’re looking for some value but you’re not sure if it’s first, second, third, or anywhere else.
In general you should never get into that situation. It’s not easy to find index of a specific item. Instead of trying to do that you should pre-process the results.
Are you looking for a specific value? Use ‘Filter array’ before accessing the item to remove everything but that item from the array. Apply first(…) on the outcome and you’re done.
Are you looking for the highest/lowest value? Use the sort(…) expression to sort the array first. Move the desired item to the top or to the end of the array and then use first(…) or last(…).
When you navigate in an array in your Power Automate flow, you must always know what you’re looking for. Is it the first or last item? Use the first(…) or last(…) expression on the array. Is it always Nth item? Use the [index] to get the value. Don’t know the position of the value? Preprocess the array with sorting or filtering that’ll allow you to use one of the expressions or the index.
Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?
I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.
All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.
Zero spam, unsubscribe anytime.
The post How to navigate in an array within Power Automate flow appeared first on Let's POWER Automate.
“I have two numbers, they’re the same, yet the condition in Power Automate evaluates as ‘false’ when comparing them!”
Comparing two numbers is such a common functionality in many Power Automate flows. You have two numbers and depending on their comparison the flow will do something. It can be a backup column to avoid infinite trigger loop via trigger condition, a rating from Forms, or just any two numbers. Yet even if the numbers look the same in the flow, when used in a ‘Condition’ it always returns ‘false’! Why? Why does it tell you that it’s not the same number even though you can see it is?
If the ‘Condition’ doesn’t work you encountered a problem with different data types. There’s a difference whether the number is a number or a “text” that contains the number character. If they’re not the same type the ‘Condition’ can be evaluated as ‘false’.
To get the desired result you must convert both the values to the same type. There’re two expressions to convert a ‘number’ into a number.
The first one is int(…) that’ll convert a numeric value into an integer.
int(<number>)
Note: <…> is a placeholder, replace it including the < and >.
But it must be a whole number with no decimal places. Once you try to convert a decimal number into integer the action will fail.

As such the int(…) expression is a good solution only when you’re 100% sure that the number won’t have any decimal places, e.g. when working with a date.
If your number can contain also decimal places, use the float(…) expression. This expression is more generic as it doesn’t care about the number format. If it’s a whole number – fine; if it’s a decimal number – also fine.
float(<number>)
Note: <…> is a placeholder, replace it including the < and >.

Once you have the numbers in the same format it should evaluate the conditions correctly.
When your Power Automate condition always returns ‘false’, even though you can see that the numbers are the same, try to play with the data type. There’s a chance that one of the numbers is a text, not a number, and Power Automate doesn’t like that. Take both sides of the condition and convert them into the same data type. If they’re whole numbers, you can use the int(…) expression, but once decimal numbers come into play you’ll have to use float(…).
Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?
I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.
All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.
Zero spam, unsubscribe anytime.
The post Why the condition is false for the same numbers (Power Automate) appeared first on Let's POWER Automate.
PVARegExHeaderIMG
![]()
jcook127001
![]()
![]()
![]()
![]()
![]()
![]()
FeatureIMG
![]()
jcook127001
![]()
![]()
![]()
![]()
![]()
![]()
![]()
feature IMG
![]()
jcook127001
![]()
![]()
![]()
![]()
![]()
![]()
![]()
FeatureIMG
![]()
jcook127001
![]()
![]()
![]()
![]()
![]()