Average per Week by Formula in Excel

We usually apply AVERAGE function or relevant functions to return average directly in Excel worksheet. But in some situations, only applying average relevant functions cannot figure out our problem. Sometimes we can create a formula with functions and mathematical operation inside to calculate average depends on different situations.

In this article, through explaining the example below, we will introduce you to apply SUMPRODUCT and COUNTIF functions together to calculate average. You can get the basic knowledge and usage of these two functions in this article.

EXAMPLE

Average per Week 1

The unit for “Amount” is pound. The unit for “Unit Price” is one dollar a pound. From the table we can know that unit prices are fluctuant every week. In different weeks, we bought different amounts of item per our demands. For example, on week-1, we bought 10 pounds with a unit price $9.99, but on week-3, we didn’t pay for this item. Now, we want to know the average of our consumption per week, and the average of unit price we cost for five weeks.

In this article, to approach our goal, we will apply SUMPRODUCT function and COUNTIF function, and use an expression =SUMPRODUCT()/COUNTIF() to get the average of total price per week; and apply SUMPRODUCT function and SUM function, and expression =SUMPRODUCT()/SUM() to get the average of unit price for one pound during five weeks.

ANALYSIS

To calculate “average of total price per week”:

a. In mathematics, the general formula to figure out this problem is “Average=(Total price of week1 + Total price of week2 + … + total price of week N)/N weeks”.

b. To calculate the total price of each week, we can create a simple formula that multiplies amount by unit price, for example, for week1, total price is B2*B3.

c The total price of all five weeks is equal to (B2*B3+C2*C3+…+F2*F3). Actually, this operation can be seen as two arrays multiplication that “values from range B2:F2 multiply the values from range B3:F3” correspondingly, then sum all products properly. Till now, we are sure we can apply Excel Math function “SUMPRODUCT” here to sum total price of five weeks simply.

d. For number of weeks, as there is no consumption on week-3, so week-3 should be excluded when counting number of weeks. As D2 is blank, so we can apply COUNT function directly to count weeks as COUNT function can ignore blank cell automatically. To make sense, we apply COUNTIF function instead of COUNT We want to count weeks with consumption, so amount should be greater than 0. To count with one condition or criterion, we choose COUNTIF function here.

e. Then we can create a formula =SUMPRODUCT(B2:F2*B3:F3)/COUNTIF(B2:F2,”>0”) to return average.

To calculate “average of unit price per pound”:

a. In mathematics, the general formula to figure out this problem is “Average=(Total price of week1 + Total price of week2 + … + total price of week N)/Total amounts”. We can repeat above first three steps to get sum of total prices.

x
How to Show All Named Ranges in Excel

b. For total amounts, just apply SUM function which is one of the most frequently used math functions in Excel.

c. Then we can create a formula =SUMPRODUCT(B2:F2*B3:F3)/SUM(B2:F2) to return average.

FORMULA

Input formula =SUMPRODUCT(B2:F2*B3:F3)/COUNTIF(B2:F2,”>0″) into H2 and press Enter, verify that 86.46 is returned and shown in H2 properly. (10*9.99+9*9.79+8*8.99+10*8.59)/4=86.46. The return value is correct.

Average per Week 1

Notice: actually, the returned value may be a number with more than two decimal places (based on your settings), you can click “Decrease Decimal” in “Number” section under Home tab to shorten decimal places and keep only two.

Input formula =SUMPRODUCT(B2:F2*B3:F3)/SUM(B2:F2) into H4 and press Enter, verify that 9.35 is returned and shown in H4 properly. (10*9.99+9*9.79+8*8.99+10*8.59)/ (10+9+8+10)=9.35. The return value is correct.

Average per Week 1

FUNCTION INTRODUCTION

a. SUMPRODUCT function returns the sum of the products of multiplication of multiple corresponding arrays or ranges.

Syntax:

=SUMPRODUCT(array1, [array2], [array3],…)

Example.

Average per Week 1

b. COUNTIF returns the number of cells which contain a number and the number meets one condition or criterion. The condition or criterion is determined by our input in “criteria” argument.

Syntax:

 =COUNTIF(range, criteria)

Example.

Average per Week 1

c. SUM function returns sum of a set of numbers.

Syntax:

=SUM(number1,[number2], …)

Example.

Average per Week 1

EXPLANATION

=SUMPRODUCT(B2:F2*B3:F3)/COUNTIF(B2:F2,">0")

// for SUMPRODUCT, array1 is B2:F2*B3:F3

// for COUNTIF, range is B2:F2, criteria “>0”

a. SUMPRODUCT(B2:F2*B3:F3) returns the sum of total prices of all five weeks. Expand values in B2:F2 and B3:F3, we get below expression:

=SUMPRODUCT({10,9,0,8,10}*{9.99,9.79,9.69,8.99,8.59}) //

returns 345.83

b. COUNTIF(B2:F2,”>0″) returns number of weeks with consumption. Expand values from range B2:F2, we get below expression:

=COUNTIF({10,9,0,8,10},">0")//

returns “4”

c. Above all, =SUMPRODUCT(B2:F2*B3:F3)/COUNTIF(B2:F2,”>0″) returns 345.83/4=86.46.

=SUMPRODUCT(B2:F2*B3:F3)/SUM(B2:F2)

// for SUMPRODUCT, array1 is B2:F2*B3:F3

// for SUM, numbers are saved in B2:F2

a. SUM(B2:F2) returns the sum of total amounts of all five weeks. Expand values in B2:F2, we get below expression:

=SUM({10,9,0,8,10}) //

returns 37

b. As SUMPRODUCT function returns 345.83, so =SUMPRODUCT(B2:F2*B3:F3)/COUNTIF(B2:F2,”>0″) returns 345.83/37=9.35.

Related Functions


  • Excel SUM function
    The Excel SUM function will adds all numbers in a range of cells and returns the sum of these values. You can add individual values, cell references or ranges in excel.The syntax of the SUM function is as below:= SUM(number1,[number2],…)…
  • Excel SUMPRODUCT function
    The Excel SUMPRODUCT function multiplies corresponding components in the given one or more arrays or ranges, and returns the sum of those products.The syntax of the SUMPRODUCT function is as below:= SUMPRODUCT (array1,[array2],…)…
  • Excel COUNTIF function
    The Excel COUNTIF function will count the number of cells in a range that meet a given criteria. This function can be used to count the different kinds of cells with number, date, text values, blank, non-blanks, or containing specific characters.etc.= COUNTIF (range, criteria)…
  • Excel AVERAGE function
    The Excel AVERAGE function returns the average of the numbers that you provided.The syntax of the AVERAGE function is as below:=AVERAGE (number1,[number2],…)….

 

Related Posts

Case Sensitive Lookup with SUMPRODUCT and EXACT

Today, we will show you how to use SUMPRODUCT and EXACT to perform a case sensitive exact match. In this article, we provide a simple example to calculate bonus for employees whose names are case-sensitive. If you meet similar scenarios ...

How to Sum if Equal to Many Items or A Range in Excel
How to Sum if Equal to Many Items 12

If we want to sum numbers from a range with criteria, we often select SUMIF of SUMIFS functions as the first choice to create a formula. The criteria can be a number or an array or a collection of some ...

How to Sum if Equal to X or Y in Excel
How to Sum if Equal to X or Y 19

In daily work, if we want to sum numbers from a range, and only sum the numbers which being equal to X or Y in the range, we can create a formula with Excel build-in functions to get the result. ...

How To Sum the Largest N Values in Excel

Sometimes we may want to sum the largest N numbers or top N numbers in a range. In this article, we will show you the method of “SUM the Largest N Numbers” by a simple formula which consist of SUMPRODUCT ...

How to Sum for Cell Contains Formula Only in Excel
How to Sum for Cell Contains Formula Only in Excel 9

Sometimes values are created by formulas in cells. If we want to sum values which are created by formulas from a range, but some values which are hardcoded also list in the same range, how can we filter out matched ...

How to Sum the Smallest N Values in Excel
How to Sum the Smallest N Values in Excel 15

Sometimes we may want to sum the first smallest N numbers in a range in Excel. In this article, we will show you the method of “SUM the Smallest N Numbers” by a simple formula which consist of SUMPRODUCT and ...

How to Sum by SUMPRDUCT with One Specific Criteria Multiple Columns in Excel
How to Sum by SUMPRDUCT with One Specific Criteria Multiple Columns in Excel1

Sometimes we may meet the case that to sum numbers based on one specific criteria. In this article, we will show you the method to resolve this problem by formula with the help of Excel SUMPRODUCT function. SUMPRODUCT can filter ...

How to Sum by SUMPRDUCT with Specific Criteria in Excel
How to Sum by SUMPRDUCT with Specific Criteria in Excel 15

Sometimes we may meet the case that to sum numbers based on two or more specific criteria. In this article, we will show you the method to resolve this problem by formulas with the help of Excel SUMPRODUCT function. SUMPRODUCT ...

How to Count Unique Numeric Values in a Range in Excel
count unique numberic values7

This post will guide you how to count unique numeric values in the given range in Excel 2013/2016 or Excel office 365. How do I count the unique numeric values in a list of data with some duplicate values using ...

How to Count Unique Dates in Excel

This post will guide you how to count unique dates in a given range in Excel 2013/2016 or Excel office 365. How do I count the unique dates in a list of dates with some duplicate dates using a formula ...

Sidebar