Use Case: Power Automate Flow - Trigger condition expression - SharePoint Columns Compare and trigger only if not equal.
If you are looking for a trigger expression to cut down the unnecessary amount of flow runs as we use trigger action on item create/modify. In this article, we will discuss the trigger expression, which will compare a couple of SharePoint columns, check whether both values are the same or different, and trigger the flow only if both values DO NOT match. I used this condition in an Approval Flow to avoid an infinite loop of the flow on every item modified or created.
Let's begin the process:
To start creating a flow, we navigate to the MS Flow portal - Power Automate - MS FLOW which opens below site :
Now, you need to sign in and click on My Flows :
We will give a name to the flow (Test flow here) and select the trigger condition as below (in my case, I used a SharePoint library) :
Now, mention/select the SharePoint site URL and library name :
Then click on Settings as shown below :
Then click on Add under Trigger Condition :
Now, here is the important expression which we will use:
Please note the SharePoint Column names I've used in the example below for comparison are: "Policy Status" and "Previous Policy Status". Another point to note is "Policy Status" this column type is a drop-down in SharePoint Library, and "Previous Policy Status" is used as a Text column.
You can change or update those column names as per your use.
Mention or copy-paste it as shown below and click on Done :
@not(equals(triggerOutputs()?['body/Policy_x0020_Status/Value'],triggerOutputs()?['body/Policy_x0020_Previous_x0020_Status']))
So, this expression will make our flow trigger only when both status column values are different (not equal values)
I hope this helps, happy learning! :-)