The Power Automate Variables function returns the value of the given variable that is passed to the function by its variable name.
In this article, I’ll introduce you to the variables function and will provide a step-by-step guide on how to use the function in a Microsoft flow.
Power Automate Variables Function
Power Automate Variables Function
Return the value of a variable by providing its name as input parameter.
Syntax
variables('<variableName>')
Input parameters
- variableName (mandatory): The variable name of the variable whose value should be returned.
Return value
- Returns the value of the given variable.
Power Automate Variables Expression Example
variables('myVar') // if myVar = 'John'
=> 'John'
How To Use The Power Automate Variables Function
Follow the steps to use the Power Automate Variables function in a flow.
-
Create a new flow with trigger ‘Manually trigger a flow’
New flow
-
Add a new step by clicking on ‘+ New step’
Add a new step
-
Search for ‘initialize’ and click on ‘Initialize variable’
Add Initialize variable action
-
Setup Initialize variable: 1) Provide a name, 2) select type String, 3) Set value to ‘Hello!’
Setup variable
-
Add a compose step by searching for ‘compose’ and clicking on ‘Compose’
Add Compose action
-
Setup compose action: 1) click into Inputs (popup appears), 2) click on ‘Expression’, 3) set expression to ‘variables(‘myVar’)’ 4) click on ‘OK’
Setup variables expression in Power Automate
-
Save and do a test run
Result test run – Power Automate variables function example