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 Automate - Building Flows
Answered

Need to sum the output - please help

(0) ShareShare
ReportReport
Posted on 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

I have the same question (0)
  • Suggested answer
    Daniel Bocklandt Profile Picture
    5,011 Super User 2025 Season 2 on at
    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. 
  • CU18100238-0 Profile Picture
    10 on at
    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 


  • Daniel Bocklandt Profile Picture
    5,011 Super User 2025 Season 2 on at
    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. 
  • Suggested answer
    Meekou Profile Picture
    200 Moderator on at
    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
  • CU18100238-0 Profile Picture
    10 on at
    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
    Daniel Bocklandt Profile Picture
    5,011 Super User 2025 Season 2 on at
    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.   
  • Daniel Bocklandt Profile Picture
    5,011 Super User 2025 Season 2 on at
    Need to sum the output - please help
    Hey 
     
    Just a follow up has your problem been resolved?
  • CU18100238-0 Profile Picture
    10 on at
    Need to sum the output - please help
    Hi @DBO_DV & @Meekou 

    Thank you so much, It worked!!!

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 597 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 373 Moderator

#3
chiaraalina Profile Picture

chiaraalina 262

Last 30 days Overall leaderboard