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 / KPI Tracker & Automati...
Power Automate
Suggested Answer

KPI Tracker & Automation of trend calculation

(1) ShareShare
ReportReport
Posted on by 10
Hi all, 

I'm at a loss of how to proceed.. I am fairly new to Power Automate, so I'm unsure if I've failed to see an easily solution or I've started something that isn't possible to create within PA.

I have created a flow that populates a table in an excel sheet from a MS list, with filtered data.
Columns are as follows:
- Task Name
- Category
- Start date
Completed Date

Now I want to create another flow that does the following:

- Calculates the time tasks have taken to be completed in the last 30 days.
      - Populates this number into another table that only has 1 row, with three columns "Prev. Average, Current Average & Trend".
What I want to create is a flow that updates every wednesday at a certain time (Done), then it needs to first save the current average entry, and place that in the Prev. Average column, then it needs to calculate the new average (Completed past 30 days) and populate it in the "Current Average", then I need a trend calculation that calculates the difference in days between prev. average & current average. 

Is this possible, and if yes, how? 
 
Categories:
I have the same question (0)
  • Suggested answer
    CA1105 Profile Picture
    545 Super User 2025 Season 2 on at
     
    Seems doable to me. You can follow below steps and try to start creating the flow.
     
    1. Create schedule flow and trigger should be set to run on every Wednesday.
    2. Save the current average entry, and place that in the Prev. Average column.
    3. Get all the tasks from table in an excel sheet or MS list filtered using which has completed in last 30 days.
    4.  Calculate Current Average and store in one of the column of your choice.
    5.  Now for calculating between prev. average & current average. you can create one column in table which is of type calculated.
     
    Feel free to modfiy the process according to your need since I've give you high level steps and something to start with.
     
  • NS-13050854-0 Profile Picture
    10 on at
    I for some reason can't reply to your response @CA1105 directly.

    I have understood the idea behind the flow, even used chatgpt to try and actually create it but it isn't working. 
    I am not seeking help to create ideas on the basic structure of the flow, I'm seeking help to do it step by step (It's a lot to ask, I know). 

    But your answer sadly doesn't get me any further than I've already gotten, though I appreciate the reply!
  • Suggested answer
    Riyaz_riz11 Profile Picture
    3,893 Super User 2025 Season 2 on at
    HI,
     
    Step 1: Schedule the flow
    Use Recurrence trigger:
    Frequency: Weekly
    Interval: 1
    On these days: Wednesday
    Time: set your desired time
    Step 2: List rows from your Excel table (tasks)
    Use Excel Online (Business) → List rows present in a table
    Connect to the Excel file & table that contains your tasks
    (Optional) If your Excel is in OneDrive or SharePoint, select the location & document library accordingly
    Step 3: Filter rows to only completed tasks in the last 30 days
    Since Power Automate’s Excel connector doesn’t support complex OData filters on dates, filter in the flow:
    Add a Filter array action
    From: value output of the previous Excel action (all rows)
    Condition:

    and(
        not(empty(item()?['Completed Date'])), 
        greaterOrEquals(formatDateTime(item()?['Completed Date'], 'yyyy-MM-dd'), formatDateTime(addDays(utcNow(), -30), 'yyyy-MM-dd'))
    )

    This filters rows where:
    Completed Date is not empty
    Completed Date is within the last 30 days
    Step 4: Calculate average completion time (days)
    Add Initialize variable (name: totalDays, type: Integer, value: 0)
    Add Initialize variable (name: taskCount, type: Integer, value: 0)
    Add an Apply to each — loop through filtered array from Step 3
    Inside loop:
    Calculate days between Start date and Completed Date for each task:

    sub(
        ticks(item()?['Completed Date']), 
        ticks(item()?['Start date'])
    )

    This gives ticks, so divide by number of ticks in a day:
    Number of ticks in a day = 864000000000
    So days =
    div(sub(ticks(item()?['Completed Date']),ticks(item()?['Start date'])),864000000000)
    Add to totalDays variable:
    Use Set variable or Increment variable action:
    totalDays = totalDays + daysDifference
    Increment taskCount by 1
    After the loop, calculate average:
    Initialize variable currentAverage (Float)
    Use Set variable with expression:
    if(equals(variables('taskCount'), 0), 0, div(variables('totalDays'), variables('taskCount')))
    Step 5: Read the current Prev. Average and Current Average values from the "summary" Excel table
    Use Excel Online (Business) → List rows present in a table on the summary table that has columns: Prev. Average, Current Average, Trend
    Since it only has 1 row, get that row's values:
     
    prevAverage = float(item()?['Prev. Average'])
    currentAverageOld = float(item()?['Current Average'])
    Step 6: Update the summary table row
    Use Excel Online (Business) → Update a row action
    For the single row in summary table:
    Set Prev. Average = currentAverageOld (the current average before update)
    Set Current Average = currentAverage (calculated in Step 4)
    Set Trend = currentAverage - currentAverageOld

    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.
    Regards,
    Riyaz

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

#2
Tomac Profile Picture

Tomac 296 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard