Obtain the number, total, average, maximum, and minimum of the numbers in the list.

08/07/2023

Japanese version.

Learn how to get the number, total, average, maximum, and minimum of numbers in a list in Power Automate Desktop.

Steps

In all cases, first prepare a list of numbers in some way.

Numbers of counts

You can get the number of counts with the %List variable.Count%.

Total

The flow is as follow.

``````SET NumList TO [2, 5, 10, -8, 6]
SET Sum TO 0
LOOP FOREACH CurrentItem IN NumList
Variables.IncreaseVariable Value: Sum IncrementValue: CurrentItem
END
Display.ShowMessageDialog.ShowMessage Title: \$'''Total''' Message: Sum Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False ButtonPressed=> ButtonPressed
``````

After creating the list variable, the Set Variable action prepares a variable for the total value.

This variable is initialized with 0.

Then loop through the list variable with For Each.

Specify the list variable as the "Value to iterate".

Place "Increase variable" in "For Each".
Then specify %Total variable% for the variable name and %CurrentItem% for the number to increase.

After the loop completes, the total value variable will contain the total in the list.

Average

Divide the total calculated in the preceding procedure by the number of cases.

``%Sum / NumList.Count%``
``````SET NumList TO [2, 5, 10, -8, 6]
SET Sum TO 0
LOOP FOREACH CurrentItem IN NumList
Variables.IncreaseVariable Value: Sum IncrementValue: CurrentItem
END
Display.ShowMessageDialog.ShowMessage Title: \$'''Average''' Message: Sum / NumList.Count Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False ButtonPressed=> ButtonPressed
``````

Maximum

The flow is as follow.

``````SET NumList TO [2, 5, 10, -8, 6]
SET Max TO 0
SET First TO \$'''True'''
LOOP FOREACH CurrentItem IN NumList
IF (First = True OR Max < CurrentItem) = True THEN
SET First TO \$'''False'''
SET Max TO CurrentItem
END
END
Display.ShowMessageDialog.ShowMessage Title: \$'''Maximum''' Message: Max Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False ButtonPressed=> ButtonPressed
``````

After creating the list variable, the Set Variable action prepares a variable with the maximum value.

Initialize this variable with 0.

Prepare a decision variable (logical type) for the first item.

Initialize this variable with %True%.

Then loop through the list variable with For Each.

Specify the list variable as the "Value to iterate".

Place an "If" in the "For Each" and set the condition as follows.

Set up a Set Variable in the "If".

Set the decision variable for the first item to %False%.

In addition, specify %CurrentItem% as the variable for the maximum value.

After the loop completes, the variable with the largest value will contain the largest value in the list.

Minimum

If you change the variable name (optional) and the "If" condition (reverse the inequality sign) of the maximum value flow described above, it becomes a flow to obtain the minimum value.

``````SET NumList TO [2, 5, 10, -8, 6]
SET Min TO 0
SET First TO \$'''True'''
LOOP FOREACH CurrentItem IN NumList
IF (First = True OR Min > CurrentItem) = True THEN
SET First TO \$'''False'''
SET Min TO CurrentItem
END
END
Display.ShowMessageDialog.ShowMessage Title: \$'''Minimum''' Message: Min Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False ButtonPressed=> ButtonPressed
``````

For those who want to learn Power Automate Desktop effectively

The information on this site is now available in an easy-to-read e-book format.

Or Kindle Unlimited (unlimited reading).

You willl discover how to about basic operations.

By the end of this book, you will be equipped with the knowledge you need to use Power Automate Desktop to streamline your workflow.