# SUBTOTAL Function in Excel

Returns an aggregate result for data provided

## What is the SUBTOTAL Function in Excel?

The SUBTOTAL Functionin Excel allows users to create groups and then perform various other Excel functions such as SUM, COUNT, AVERAGE, PRODUCT, MAX, etc. Thus, the SUBTOTAL function in Excel helps in analyzing the data provided.

### Formula

SUBTOTAL = (method, range1, [range2 …range_n])

Where method is the type of subtotal you wish to obtain

Range1,range2…range_n is the range of cells you wish to subtotal

### Why do we need to use SUBTOTALS?

Sometimes, we need data based on different categories. SUBTOTALS help us to get the totals of several columns of data broken down into various categories.

For example, let’s consider garment products of different sizes manufactured. The SUBTOTAL function will help you to get a count of different sizes in your warehouse.

### How to use the SUBTOTAL Function in Excel?

There are two steps to follow when we wish to use the SUBTOTAL function. These are:

1. Formatting and sorting of the provided Excel data.
2. Applying SUBTOTAL to the table.

Let’s understand this Excel function with the help of an example. We use data provided by a garment manufacturer. He manufactures T-shirts of five different colors, i.e., White, Black, Pink, Green, and Beige. He produces these T-shirts in seven different sizes, i.e. 2, 4, 6, 8, 10, 12, 14. The relevant data are below: The warehouse manager provides random data. Now for the analysis, we need to get the total number of T-shirts of each color lying in the warehouse.

#### Step 1

First, we need to sort the worksheet on the basis of data we need to subtotal. As we need to get the subtotals of T-shirts by colors, we will sort it accordingly.

To do that, we can use the SORT function under the Data tab. #### Step 2

The next step would be to apply the SUBTOTAL function. This can be done as shown below:

Select the Data tab, and click on SUBTOTAL. When we click on it, the Subtotal dialogue box will appear as shown below: Now, click the drop-down arrow for the “At each change in: field.” We can now select the column we wish to subtotal. In our example, we’ll select Color. Next, we need to click the drop-down arrow for the “Use function: field.” This will help us select the function we wish to use. There are 11 available functions. We need to choose depending on our requirements.  In our example, we’ll select SUM to find out the total number of T-shirts lying in each warehouse. Next, we move to “Add subtotal to: field.” Here we need to select the column where we require the calculated subtotal to appear. In our example, we’ll select Number of Units in Warehouse I and Warehouse II. After that, we need to click OK and we will get the following results: As we can see in the screenshot above, the subtotals are inserted as new rows below each Group. When we create subtotals, our worksheet is divided into different levels. Depending on the information you wish to display in the worksheet, you can switch between these levels.

The level buttons in our example are images of buttons for Levels 1, 2, 3, which can be seen on the left side of the worksheet. Now suppose I just want to see the total T-shirts lying in the warehouse of different colors, we can click on Level 2. If we click on the highest level (Level 3), we will get all the details.

### Tips for the SUBTOTAL function:

#### Tip #1

Let’s assume, we wish to ensure that all colors of T-shirts are available in all sizes in either of the warehouses. We can follow these steps:

Step 1: Click on Subtotal. Remember we are adding one more criterion to our current Subtotal data. Now,

Step 2: Select COUNT from the drop-down menu, and Size from the “Add subtotal field to.” After that, uncheck the “Replace current subtotals.” Once you click OK, you will get the following data: This will help us ensure that the count for different sizes and we can sort data in such a manner that the repetitions are not there.

#### Tip #2

Always sort data by column we will use to subtotal.

#### Tip #3

Remember that each column we wish to subtotal includes a label in the first row.

#### Tip #4

If you wish to put a summary of the data, uncheck the box “Summary below the data when inserting Subtotal.”

### Free Excel Course

Check out our Free Excel Crash Course to learn more about Excel functions using your own personal instructor. Master Excel functions to create more sophisticated financial analysis and modeling towards building a successful career as a financial analyst.
{"ft_lang_label":"__label__en","ft_lang_prob":0.8673676,"math_prob":0.78344303,"size":5176,"snap":"2023-40-2023-50","text_gpt3_token_len":1131,"char_repetition_ratio":0.123163186,"word_repetition_ratio":0.019274376,"special_character_ratio":0.21271253,"punctuation_ratio":0.12440191,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.95771664,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-09-21T13:18:24Z\",\"WARC-Record-ID\":\"<urn:uuid:1693d077-585b-4bc6-9fc7-d8e81c1bbec2>\",\"Content-Length\":\"138319\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:ee31b06b-7f6b-4d72-a238-08837ab9541e>\",\"WARC-Concurrent-To\":\"<urn:uuid:70459886-6293-4478-938e-3bd07742e19e>\",\"WARC-IP-Address\":\"104.22.28.212\",\"WARC-Target-URI\":\"https://corporatefinanceinstitute.com/resources/excel/subtotal-function-in-excel/\",\"WARC-Payload-Digest\":\"sha1:SSCDQK2MPNIPCFAIGUOZK3PS6HEZMWBD\",\"WARC-Block-Digest\":\"sha1:7KKKOAOADMFKTTY6QVYEYH2A7OBO3MV5\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-40/CC-MAIN-2023-40_segments_1695233506027.39_warc_CC-MAIN-20230921105806-20230921135806-00766.warc.gz\"}"}