BA Lesson 4
BA Lesson 4
=SUM(value1,value2….)
The benefit of the “SUM” function over “+” operator is that it is able to handle a large range of values without the
user having to enter each cell reference individually. Let’s see this in practice in our dataset.
When performing sum operations over a range, instead of entering each cell reference individually, this syntax
become
Let’s say we want to add the number of reviews for TCS and Accenture -
=SUM(47000, 31200)
This obviously does not have any benefit over the “+” operator
=SUM(D2,D3)
This also does not have any benefit over the “+” operator
But let’s say you want to add the number of reviews for the first 100 companies. With the “+” operator, this
becomes
=D2+D3+D3+......D101
Typing this entire formula out will be almost impossible. This is where the SUM function really shows its benefit.
This calculation with SUM is simply
=SUM(D2:D101)
But this is not all - Excel can also add multiple ranges in a single SUM function. Let’s say you want to add the
first 100 numbers, and to it, add numbers in rows 301 to 401. This is very simply
=SUM(D2:D101,D301:D401)
These ranges need not necessarily be in the same column. The following function will also work assuming all
the entries in the range are numbers.
=SUM(D2:D101,F2:F101)
In our dataset, this will naturally give an error because entries in column F are not numbers.
SUMIF
Let’s say in our dataset we want to calculate the sum of the number of reviews of companies that are tagged
as IT Services & Consulting. How do you do this?
One way to do this is to filter the companies which have the tag as “IT Services & Consulting”, copy the data to
another sheet, and use the SUM function.
The better way to do this is with SUMIF. As the name suggests, it will only SUM values IF a single specified
condition is satisfied.
In the case mentioned above, the criteria range will be the column where tags are recorded.
Criterion is the condition - each value in the criteria range is checked against this condition, and only those are
selected which meet the condition.
And the sum range will be the column where the number of reviews are recorded. Here it becomes
What SUMIF does is, it selects the criteria range, and the criterion, identifies the entries in the criteria range
which matches the criterion, and only adds those corresponding entries.
Interestingly, sum range is optional in this formula - if sum range is not specified, the formula assumes criteria
range as the sum range.
Let’s calculate the total number of reviews for companies who have been rated 3.9. Here the formula becomes
=SUMIF(C2:C9960,3.9,D2:D9960)
As you can see, whenever a text string is used, we put it in double quotes, and whenever a number is used, we
put it without quotes.
This is also a good point to learn about basic excel comparison operators -
In the case of SUMIF, we can define our criterion using logical operators also
We use double quotes also when we use a logical operator. For example, if we want to calculate the total
number of reviews above 3.9 in the dataset,
=SUMIF(C2:C9960,”>3.9”,D2:D9960)
Exercise - Create a new sheet called “Sum of each tag” and calculate the sum of at least 5 tags in the following
format -
SUMIFS
What about a case where you want to find the number of reviews for all Internet companies that are Private?
Here, because you have multiple conditions - Tags = Internet, Company_type = Private, SUMIF will not help.
This is where SUMIFS helps. This is a function that adds based on more than one criteria being matched.
Syntax: =SUMIFS(sum range, criteria 1 range, criteria 1, criteria 2 range, criteria 2,....)
Criteria 1 range is the range of values from which criteria 1 needs to be checked
Criteria 1 is the condition which needs to be met in criteria 1 range for the value to be added
Exercise - Calculate the total number of reviews for all IT Services and Consulting companies that have rating
greater than 3.
Average
In Excel, calculating the average of a set of values is done with the AVERAGE functions
For example,
=AVERAGE(A2:A25)
Or
=AVERAGE(A2:A25, A30:A55)
Exercise
Calculate the average rating for all the companies given in the datase
Arrange the companies in ascending order of name (A to Z) and calculate the average number of ratings in
the first 200 companies
AVERAGEIF
Similar to SUMIF, AVERAGEIF calculates the average of only those values in a set which meet a certain criterion.
The syntax for this is very similar to SUMIF
Criteria range refers to the range of values from which the function will check whether the criteria is met
Criteria is the condition - each value in the criteria range is checked against this condition, and only those are
selected which meet the condition. The average is calculated only for those values in the average range which
correspond to the selected values in the criteria range.
Similar to SUMIF, if the average range is not specified, the formula assumes the criteria range as the average
range.
Exercise
Calculate the average number of reviews received by an NGO/NPO (Company_type = NGO/NPO
Calculate the average rating of an Automobile company (Tags = Automobile)
AVERAGEIFS
This is similar to the SUMIFS function, where you can calculate the average of a set of values after having it
meet multiple criteria.
Syntax: =AVERAGEIFS(average range, criteria 1 range, criteria 1, criteria 2 range, criteria 2,....)
Exercise
Calculate the average rating received by Public IT Services & Consulting companies
Count
COUNT function goes through the given range and counts the number of cells in the range that contain
numeric data
Similar to SUM and AVERAGE, the function can also take a range
For examples
=COUNT(A2:A35,A40:A200)
Exercise -
Count the number of ratings that has been populated in the dataset
COUNTA
COUNTA function counts the number of cells in a range that are not blank. Any kind of entry - numeric or text, is
counted by this function. This means that if there is any entry in a cell - be it numbers or text, it will be counted
by the function
The opposite of COUNTA is COUNTBLANK function, which counts the number of blank cells in a range. Syntax
=COUNTBLANK(range)
Exercise
Use COUNTA to calculate the number of missing entries in the No. of Employees column
COUNTIF
Similar to AVERAGEIF, COUNTIF calculates the number of only those cells in a set which meet a certain criterion.
Unlike SUMIF and AVERAGEIF, there is no provision to give a separate criteria range and count range - the
criteria is checked in the range, and the counting is done in the same range.
Exercise
Use COUNTIF to calculate the number of missing entries in the No. of Employees colum
Use COUNTIF to calculate the number Manufacturing companies in the dataset (tags = Manufacturing)
COUNTIFS
COUNTIFS evaluates multiple criteria and calculates the number of cells that match all criteria.
Exercise
Calculate the number of FMCG companies that are private in the datase
Calculate the number of Financial Services companies which are rated higher than 4
MAX and MIN are two simple functions - they return the maximum and minimum numeric value in a dataset
Syntax:
=MAX(value1, value2,...)
=MIN(value1, value2,...)
Like the other functions discussed so far, these can also take range as input
Exercise
Find the maximum rating received by a company in the datase
Find the number of companies that received the maximum rating (use COUNTIF and MAX together)
Final Exercise
In the dataset, calculate the number NBFC companie
Calculate the number of Public NBFC companie
Calculate the average rating received by an NBFC compan
Calculate the total number of reviews received by NBFC companies that have rating >4.0
Ctrl + Space It is used to select the entire column of the current cell