SUBTOTAL

Returns a subtotal for a vertical range of cells using a specified aggregation function. Learn more

Video field
Math

In Google Sheets, the SUBTOTAL function calculates the subtotal of a range of data based on a specified function code. It is commonly used to perform calculations on filtered or grouped data.

Here's how it works:

The "function_code" parameter specifies the type of calculation you want to perform. It is a number that corresponds to a specific function. The function codes range from 1 to 11 and 101 to 111. Each code represents a different function, such as SUM, AVERAGE, COUNT, MAX, MIN, and more. The function codes from 1 to 11 include hidden rows, while the function codes from 101 to 111 exclude hidden rows.

The "range1" parameter represents the first range of data you want to include in the calculation. This can be a single cell, a range of cells, or a named range.

Optionally, you can include additional ranges (range2, range3, etc.) separated by commas to calculate the subtotal across multiple ranges.

The SUBTOTAL function ignores other SUBTOTAL functions within its range to avoid double-counting.

Here's an example of how to use the SUBTOTAL function in Google Sheets:

Let's say you have a range of values in cells A1 to A10, and you want to calculate the sum of only the visible cells (excluding hidden rows). You can use the following formula:

=SUBTOTAL(9, A1:A10)

In this example, the function_code 9 corresponds to the SUM function that includes only visible cells.

Want even more from Google Sheets?


With Softr, you can turn your spreadsheets into powerful web apps.You can give advanced roles and permissions to each user, build advanced logic and automation flows, customize the design to your needs, and much more.


Softr also offers a growing library of templates for internal tools, client portals, community hubs, and more. The templates come with a Google Sheet or an Airtable base that you can use to store and manage your data easily.


Try Softr now and build your custom web apps in 10 minutes no code required!