web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Initializing variables...
Power Automate
Unanswered

Initializing variables using logical expressions - how to learn power automate language

(0) ShareShare
ReportReport
Posted on by 2

Hi,

 

Very new here.

 

I would like to initialize variables in my flow that use logical expressions to determine their value.

 

For example:

 

- The user inputs their answer as "Cat" into a form.

 

- I initialize a variable "userInputVar" and give it a value of "Cat"

 

- I want to initialise a variable whose value follows a logical formula such as "=if( userInputVar = "Cat", "The cat sat on the mat", "No cats here").

 

Please would you tell me how to actually write this in whatever language PowerAutomate allows input in.

 

Could you alternatively, or as well, link to good resources that describe the basic logical expressions available in the power automate expressions box so that I can understand how to refer to variables and correctly write if, and, or and not statements.

 

Thank you for any time, 

 

G

Categories:
I have the same question (0)
  • Verified answer
    David_MA Profile Picture
    12,966 Super User 2025 Season 2 on at

    You are close in your approach. The expression would be:

    if(equals(triggerBody()['text'], 'Cat'), 'The cat sat on the mat.', 'No cats here.')

    Replace triggerBody()['text'] with the dynamic content of your userInputVar. 

    David_MA_0-1701895574516.png

    Note, this is case-sensitive, so if someone enters "cat" instead of "Cat" there will not be a match and it will return no cats here. If you don't care about case, you would use this expression:

    if(equals(toLower(triggerBody()['text']), 'cat'), 'The cat sat on the mat.', 'No cats here.')

    It will then accept, cat, Cat, cAt, CAT, etc.

  • FinkNottle Profile Picture
    2 on at

    Hi David,

     

    Thank you very much!

     

    Using this I've now got it to work - so will be able to continue with this little project 🙂

     

    For reference I wanted to call a user input variable from a microsoft form and in order to refer to the user input object I used the code:

     

    FinkNottle_0-1701964880981.png

     

    Where 

     

    outputs('Get_response_details')?['body/ra9ecaf5c2d194034b522b3013fe93343']
     
    is the unsightly bit of code that refers to the user input.
     
    Is there a more concise way of referring to user inputs, collected from a form?
     
    Further, is there anywhere online that I can learn about the coding language: for instance understanding how to call user responses or initialized variables?
     
    Thanks again,
     
    G

     

  • David_MA Profile Picture
    12,966 Super User 2025 Season 2 on at

    What you are doing is the correct way to reference fields from your form. With Microsoft forms the fields reference the GUID value instead of the internal name like with SharePoint so it is sometimes difficult to know what field you are referencing, but it is correct.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard