Skip to main content

Notifications

Community site session details

Community site session details

Session Id : QQx0j0aLoJxVMCfpu+8UaM
Power Automate - Building Flows
Answered

Put Variables in Apply to each loop

Like (0) ShareShare
ReportReport
Posted on 18 Aug 2021 03:49:20 by 45

Hi Team I am facing a issue below, please help me to resolve this

Step 1: I have initialized a variable diffdates as integer, which I want to find the difference of day (today, task end date)

 

Prajnya_0-1629256784766.png 

Below in the Apply to each loop, I am trying to find out the values using some formula in Set Variable

Prajnya_1-1629257886617.png

Prajnya_2-1629258004972.png

Prajnya_3-1629258235173.pngPrajnya_4-1629258261771.png

Like I have added Task Name and its corresponding Project Name in the Email body I want the DateDiff of the corresponding tasks to be displayed. 

Below I have attached the email

Prajnya_5-1629258320542.png

Please help me in this. Thank you in advance.

 

 

 

  • v-bofeng-msft Profile Picture
    on 18 Aug 2021 at 08:42:27
    Re: Put Variables in Apply to each loop

    Hi @Prajnya :

    This is due to the nested structure of your flow: the body of the email is actually completed in ”apply to each3“, because ”apply to each3“ is a sub-loop of ”apply to each 2“, so the datediff obtained in the body of the email is always current A fixed value of ”apply to each 2“ loops.

    My suggestion is to reorganize the structure of this flow.

    Best Regards,

    Bof

  • Prajnya Profile Picture
    45 on 18 Aug 2021 at 08:19:04
    Re: Put Variables in Apply to each loop

    Hi @v-bofeng-msft 

    Prajnya_0-1629274244311.png

    Prajnya_1-1629274316997.pngPrajnya_2-1629274377830.png

    Prajnya_5-1629274563542.png

     

     

     

    When I run the flow

    Prajnya_3-1629274453138.pngPrajnya_4-1629274487002.png

    Attached here the Email

     

    Prajnya_6-1629274728948.png

     

     

    The Date diff it is taking as 84 for all tasks. not forming array for this. 

     

  • Prajnya Profile Picture
    45 on 18 Aug 2021 at 08:05:40
    Re: Put Variables in Apply to each loop

    Hi @v-bofeng-msft 

    I just wrongly presses Accept as solution, please be with me I am sending the instances I have tried, Thanks

  • Verified answer
    v-bofeng-msft Profile Picture
    on 18 Aug 2021 at 07:57:42
    Re: Put Variables in Apply to each loop

    Hi @Prajnya :

    I noticed that you have obtained the correct value and saved it in a variable. Why can't you call this variable directly?

    Could you please tell me what is the meaning of "But not able to form an array in the EmailBody"?Do you you want to group these dates into an array?If so,you could try "append to an array" action.

    Best Regards,

    Bof

  • Prajnya Profile Picture
    45 on 18 Aug 2021 at 07:00:31
    Re: Put Variables in Apply to each loop

    Hi @v-bofeng-msft 

     

    Thank you for your quick response

    Yes, I am getting correct Date Difference Value in this Step,

     

    But not able to form an array in the EmailBody

    Please find my below images, I am getting correct Day Difference using the same  formula you have mentioned above but I want them to be displayed in the Email also like Task name, Project Name of the Task 

    Prajnya_2-1629270009903.png

     

     

    Prajnya_0-1629269809006.pngPrajnya_1-1629269846269.png

    If insert the variable vardiffdates in the email body then it is taking 84 as the date difference of 1st task not making array, also Append to String Variable but not worked.

     

    Please help in another way, Thanks

  • v-bofeng-msft Profile Picture
    on 18 Aug 2021 at 06:23:24
    Re: Put Variables in Apply to each loop

    Hi @Prajnya :

    Sorry,I'm not sure what your current problem is.Could you please tell me :

    Did you get the correct datediff value at this step?

    vbofengmsft_0-1629267396806.png

    About how to get the number of days between two Dates

    div(sub(ticks(startOfDay(utcNow())),ticks(startOfDay('2019-05-04T08:00:00Z'))),864000000000)

    If you have obtained the correct datediff value, then just insert the variable vardiffdates in the email body.

    Best Regards,

    Bof

     

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,645 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,997 Most Valuable Professional

Leaderboard
Loading started
Loading complete