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

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Using if expressions i...
Power Automate
Unanswered

Using if expressions in flow

(0) ShareShare
ReportReport
Posted on by 129

Hello Guys, 

 

I am trying to auto mate a process such that two fields in a list are inputs from a flow copies the fields from another list and creates or updates this list B.  one field from list A is category and another is name. i want to add a flow to list B such that as the field is copied from list A and the category is "C1" it would auto populate another field for that same item in list B with value of 30 , else if it is C2 it should populate with 25   C3--- 20, C4--15, C5-- 10 . i want to use the if expression in flow or any other means to achieve this would be highly appreciated.

Thanks in advance for your response guys.

 

 

 

 

Categories:
I have the same question (0)
  • Brad_Groux Profile Picture
    4,556 on at
    Re: Using if expressions in flow

    You would Add a condition(s) to a flow. You can use expressions in conditions to check multiple values, and if you need more information about logical expressions, see the A Visual Explanation of Flow Logical Expressions (blog post).

    If you could provide an expanded screenshot of your Flow and steps we could likely better assist you.

    If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

     

  • abieba Profile Picture
    129 on at
    Re: Using if expressions in flow


    Thank @Brad_Groux  4 your swi4t response this is the 4low that does the copy and updating 4rom list A to list B 
    can i add the i4 expression in this 4low to a44ect the created or updated output.

     

    pic 1.PNGpic 2.PNG

  • efialttes Profile Picture
    14,756 on at
    Re: Using if expressions in flow

    @abieba 

    So in your Create Item action block you need to fill the "Annual leave allocated" with:

    value 30 if "Category" value is C1

    Value 25 if  "Category" value is C2

    Value 20 if  "Category" value is C3

    Value 15 if  "Category" value is C4

    Value 10 if  "Category" value is C5

    And "Annual leave allocated" column on your sharepoint list is of type Integer, right?

     

    If so, I would suggest you to:

    Step#1: just before your condition action block, create an array variable with the following pairs:

    [['C1','30'],['C2','25'],['C3','20'],['C4','15'],['C5','10']]

    I have used the following expression for such purpose:

    createArray(createArray('C1','30'),createArray('C2','25'),createArray('C3','20'),createArray('C4','15'),createArray('C5','10'))
    flow_nested_array.png

    Step#2: Add a new Apply to Each inside the 'true' branch of your condition, using the variable you created as its input

    Step#3: Include a condition inside the Apply to each, so you compare if triggerBody()?['Category']?['value'] is equal to first(item()). If true, then invoke "Create item action block" using int(last(item())) as the input for "Annual leave allocated". Leave the 'false' branch empty

    In the future, if more categories are added, then you just need to update the variable

    Hope this helps

     

     

     

  • abieba Profile Picture
    129 on at
    Re: Using if expressions in flow

    Hello @efialttes ,

    Thank you 4or your swi4t response.

    i have tried what you mentioned please see picture to con4irm. pic 2.PNG

     

    i ran it and had this error.

     

    pic 1.PNG

  • Verified answer
    efialttes Profile Picture
    14,756 on at
    Re: Using if expressions in flow

    @abieba 

    I have implemented a simulation of your flow by using a string variable called RandomCategory instead of triggerBody()?['Category']?['value'] and the execution succeeded.

     

    Flow_nested_array_2.png

     

    So, I guess the problem is when evaluating triggerBody()?['Category']?['value']. Can you add a Compose action block just before your second Condition, add triggerBody()?['Category']?['value'], reexecute the flow and verify its content?

    Hope this helps

     

  • efialttes Profile Picture
    14,756 on at
    Re: Using if expressions in flow

    Hi again

    Please remember to inspect all iterations of the Apply to Each loop to identify which one failed:

    Flow_nested_array_3.png

  • abieba Profile Picture
    129 on at
    Re: Using if expressions in flow

    Thank you @efialttes , adding the compose 4unction worked well,

    can you please explain the 4low and how those things you added works, i am actually new to these and am a bit con4used, yes it worked but i want to understand why and how.

     

     

  • efialttes Profile Picture
    14,756 on at
    Re: Using if expressions in flow

    @abieba 

    Wow! I just suggested to add the compose action block for troubleshooting purposes, so it is unclear to me why it is working now and failed before

    The Apply to each you added iterates over the array variable. So in its first execution it takes the first element from the array: ['C1','30'], the second time it takes the second element from the array: ['C2','25'], and so and so. Please note each element is also an array.

     

    In its first execution the expression first(item()) extracts the first element from ['C1','30'] : the result is the string 'C1'. In its second execution the expression first(item()) extracts the first element from ['C2','25'] : the result is the string 'C2'. And so and so.

     

    In its first execution the expression last(item()) extracts the first element from ['C1','30'] : the result is the string '30'. In its second execution the expression last(item()) extracts the first element from ['C2','25'] : the result is the string '25'. And so and so. The expression int(last(item()) converts the string into an integer.

     

    Hope this helps

  • abieba Profile Picture
    129 on at
    Re: Using if expressions in flow

    Hello @efialttes ,

     

    Seems i am running into a bit o4 trouble,

     

    a4ter the 1st addition others are coming out in multiples.

    Capture.PNG

    and its takes a while b4 it actually comes in too.

     

  • abieba Profile Picture
    129 on at
    Re: Using if expressions in flow

    Hello @efialttes , 

     

    I have seen the problem, i had another 4low causing the problem, thanks

    so in addition to that 4low, how can i add another array to select '90' if  sex is female and select '10' if male in the maternity/paternity 4ield. 

    i.e having multiple arrays b4 item is created.

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 462 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 456 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard