Skip to main content

Notifications

Community site session details

Community site session details

Session Id : ZIX7gEpvcVOl9CqrXvURxc
Power Automate - Building Flows
Answered

Need to sum the output - please help

Like (0) ShareShare
ReportReport
Posted on 21 Oct 2024 06:38:18 by 10
Hi All,

Could some one please help me with the below flow
I want a sum of from apply to each from compose 3 step.

For example i need 4 answer from the compose 3 step

  • CU18100238-0 Profile Picture
    10 on 06 Nov 2024 at 05:45:13
    Need to sum the output - please help
    Hi @DBO_DV & @Meekou 

    Thank you so much, It worked!!!
  • DBO_DV Profile Picture
    4,583 Super User 2025 Season 1 on 30 Oct 2024 at 05:59:14
    Need to sum the output - please help
    Hey 
     
    Just a follow up has your problem been resolved?
  • Verified answer
    DBO_DV Profile Picture
    4,583 Super User 2025 Season 1 on 23 Oct 2024 at 10:59:02
    Need to sum the output - please help
    Okay, now I understand better what you are trying to do. Here's how you can proceed. 
     
    First you need the distinct values of Email and Leave type so you need to

    To create a summary table using Power Automate, you need to follow these steps:

    1. Get Distinct Records:
      Use the union expression in Power Automate to get distinct values. You'll do this twice: once to get a list of unique email addresses, and once to get the unique leave types. This will give you two arrays: one for email addresses and one for leave types. follow this instruction: Get Distinct Records using the union expression in Power Automate - That API Guy
    2. Initialize Variables for Counting:
      Create a variable for each leave type to track the count of occurrences. You’ll increment these variables as you process the data.
    3. Filter the Data:
      Inside an "Apply to each" loop, iterate over the email addresses. For each email, filter the original data to get the corresponding leave records.
      For each filtered record, use loop to check the leave type and increment the appropriate variable (Each leave type will need it's own Variable) you can do this by using the switch action.
    4. Build the Result Array:
      After processing all records for one email address, create an array that includes the email and each leave type will be its own column as well.
      Append the array dircetly to another variable using the "Append to array variable" action.
      Reset the counting variables to zero after each iteration to ensure accurate counts for the next email.
    5. Result:
      At the end of the flow, the array should contain a summarized table with each email address and the counts for each leave type.
    If this solvede your porblem please accept it as solution so others can find it as well. 
    If it helped in any other way consider liking it so we can keep supporting eachother.   
  • CU18100238-0 Profile Picture
    10 on 23 Oct 2024 at 08:28:09
    Need to sum the output - please help
    Hi @DBO_DV

    Thank you for your response. 

    Here is the post which i am actually trying to get. 

    https://community.powerplatform.com/forums/thread/details/?threadid=f128c41b-fc8c-ef11-ac21-7c1e5249d4d6

    need Distinct individual and Distinct leave type & Sum of each leave type. 
  • Suggested answer
    Meekou Profile Picture
    189 Super User 2025 Season 1 on 23 Oct 2024 at 08:21:59
    Need to sum the output - please help
    For sum json array by node, you could try to convert it to xml, and then sum by xpath function.
    Regards,
    Meekou
  • DBO_DV Profile Picture
    4,583 Super User 2025 Season 1 on 23 Oct 2024 at 07:39:14
    Need to sum the output - please help
    Could you take a look at the compose that you are trying to use? 

    Seems like Power automate can not recognise it as a number. 
  • CU18100238-0 Profile Picture
    10 on 21 Oct 2024 at 10:12:07
    Need to sum the output - please help
    Hi @DBO_DV

    Thank you for the response. 

    It's actually giving me an error. Here is the complete flow that i am trying to do 


  • Suggested answer
    DBO_DV Profile Picture
    4,583 Super User 2025 Season 1 on 21 Oct 2024 at 08:01:52
    Need to sum the output - please help
    Hey there is no direct sum function.
     
    You can achieve your goal by creating a Variable (as float) before the apply to each. 
    instead of the the Compose you could add Increment variable. 
    Like this you can add the number to the previous value of the variable. 
     
     
    If you need it to run faster, there is another way that is a bit more advanced. But if you are interested in the faster way you can look it up here:
     
    If this Answered your question, please accept it as solution so others can find it as well. 
    If it helepd in any other way consider giving it a like so we can keep supporting each other. 

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Automate - Building Flows

#1
stampcoin Profile Picture

stampcoin 81

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 70 Super User 2025 Season 1

#3
David_MA Profile Picture

David_MA 48 Super User 2025 Season 1

Overall leaderboard