Forum Discussion
Como calcular a média aritimética entre varios itens (registros) de uma mesma coluna no SharePoint?
evaldobaladelli I don't know of a way to do this in SharePoint as it can't loop through the items in the list. So you either need to do something in Power Apps or build a flow in Power Automate which is what we're going to do here to get the items in your SharePoint list, loop through each one, do a calculation and save the median value of each item back in the SharePoint list.
The list in SharePoint:
In Power Automate the flow starts with a Recurrence schedule trigger. I've set it to run every 1 day but you could do it as frequently as necessary. Or perhaps use a SharePoint When an item is created trigger. Next, add 2 Initialize variable controls and make them both Float type. 1 is to store the row count and one is to store the total score.
Next add a SharePoint Get items action, select your site and list and I've set the order to ID:
Add an apply to each control and select value from the dynamic content. Inside the apply to each add 2 Increment variable controls the row count one to 1 and the total variable to the score, selected from the dynamic content box:.
Next add a Compose control and in this you will add an expression:
div(variables('varTotal'),variables('varCount'))
which will divide the current total by the current row count:
The final step is to update the SharePoint list item with the output of the Compose control.
This is the result:
Rob
Los Gallardos
Microsoft Power Automate Community Super User