In this article, we will learn How to Add Subtotals to Primary and Secondary Fields in Excel.
Scenario:
Problem here is whenever we apply a new subtotal to the same data. Previous subtotal gets removed. For example the superstore manager needs the subtotal of Categories, subcategories and month wise sales and profit. Or finding the sum of profit earned by each sales employee each month. This kind of data problem can be solved by subtotal in Excel or using a pivot table. But here we learn how to solve it by Subtotals in Excel.
Subtotal option in Excel
If you need to aggregate and group data on the basis of categories and subcategories, use the Subtotal option in excel.
To add primary subtotal in Excel
Select the table and Go to Data > Subtotal > select the grouping column name > Choose Aggregate function > select the fields you need to subtotal (multiple) > Click OK.
To add secondary subtotal in Excel.
Select the table and Go to Data> Subtotal > Select secondary grouping column name > Choose Aggregate function > select the fields you need to subtotal (multiple) > Untick Replace current Subtotal > Click OK.
Example :
All of these might be confusing to understand. Let's understand how to use the function using an example. Here we have product unit sold data with month.
We will first group data based on the month. Select the table and Go to Data > Subtotal.
select the grouping column name > Choose Aggregate function > select the fields you need to subtotal (multiple) > Click OK.
You can see the month wise subtotal data in Excel. To add more subtotal.
Again Select the table and Go to Data> Subtotal > Select secondary grouping column name > Choose Aggregate function > select the fields you need to subtotal (multiple) > Untick Replace current Subtotal
Click OK and your data will be grouped under the secondary column.
As you can see your grouped data.
Here are all the observational notes using the formula in Excel
Notes :
Hope this article about How to Add Subtotals to Primary and Secondary Fields in Excel is explanatory. Find more articles on calculating values and related Excel formulas here. If you liked our blogs, share it with your friends on Facebook. And also you can follow us on Twitter and Facebook. We would love to hear from you, do let us know how we can improve, complement or innovate our work and make it better for you. Write to us at info@exceltip.com.
Related Articles :
How to use the SUBTOTAL function in Excel : Apply aggregate functions like average, sum, count, max, min on the grouped data using the subtotal function in Excel.
How to Select Entire Column and Row Using Keyboard Shortcuts in Excel : Use Ctrl + Space to select whole column and Shift + Space to select whole row using keyboard shortcut in Excel
Paste Special Shortcut in Mac and Windows : In windows, the keyboard shortcut for paste special is Ctrl + Alt + V. Whereas in Mac, use Ctrl + COMMAND + V key combination to open the paste special dialog in Excel.
How to Insert Row Shortcut in Excel : Use Ctrl + Shift + = to open the Insert dialog box where you can insert row, column or cells in Excel.
How to use Shortcut Keys for Merge and Center in Excel : Use Alt and then follow h, m and c to Merge and centre cells in Excel.
How to use the Shortcut To Toggle Between Absolute and Relative References in Excel : F4 shortcut to convert absolute to relative reference and same shortcut use for vice versa in Excel.
Popular Articles :
How to use the IF Function in Excel : The IF statement in Excel checks the condition and returns a specific value if the condition is TRUE or returns another specific value if FALSE.
How to use the VLOOKUP Function in Excel : This is one of the most used and popular functions of excel that is used to lookup value from different ranges and sheets.
How to use the SUMIF Function in Excel : This is another dashboard essential function. This helps you sum up values on specific conditions.
How to use the COUNTIF Function in Excel : Count values with conditions using this amazing function. You don't need to filter your data to count specific values. Countif function is essential to prepare your dashboard.
The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.
"Hi,
I made a mistake above.
Your post was at 12:49AM (not PM), so the date / time value is:
37847.0340277778
Same number of days as before, but just past midnight.
Apologies for any confusion!
Alan."
"i Amanjit,
If I understand your query correctly, you are asking whether the subtotal feature can be used with times.
The answer is yes it can.
Dates and times are simply numeric values (date / time values), and can be added or subtracted like any other numbers.
For example, your post was at August 14, 2003 12:49 AM (ingoring the EST notation - I have no idea what that means!)
Excel's date / time value for that is:
37847.53402777...
This means 37,847 days since 1 Jan 1900 and 0.53402777... of a day (just past midday).
Hope that helps.
Alan."
I need to calculate UPTime from the ExcelI need to know is icon total can calculate time.
You have to pay attention to the order when you use subtotal. e.g., subtotal by Market first and then by Customer
I'm not sure if this is a bug in Excel, or just something that was never looked into, but using subtotals more than once, as in the example, does not always produce the desired results. For instance, using the example data, if the Market 'Africa' only has data for the Customer Name 'AIG', then Customer Name 'AIG' will not subtotal for 'Africa', but instead it will subtotal for 'Asia'. Also, in the opposite scenario, if the Market 'Asia' only has data for the Customer name 'Pacific Bell', then 'Pacific Bell' will not subtotal under 'Africa', but instead under 'Asia'. In other words, Excel will only force a subtotal when there is a change in the 'At each change' field. If this field is a sceondary subtotal and it is consecutive between primary subtotals, then excel will wait til the secondary filed has changed before it will force a subtotal, even if this overlaps two primary subtotals.
"Hi,
I made a mistake above.
Your post was at 12:49AM (not PM), so the date / time value is:
37847.0340277778
Same number of days as before, but just past midnight.
Apologies for any confusion!
Alan."
"Hi Amanjit,
If I understand your query correctly, you are asking whether the subtotal feature can be used with times.
The answer is yes it can. Dates and times are simply numeric values (date / time values), and can be added or subtracted like any other numbers.
For example, your post was at August 14, 2003 12:49 AM (ingoring the EST notation - I have no idea what that means!)
Excel's date / time value for that is:
37847.53402777...
This means 37,847 days since 1 Jan 1900 and 0.53402777... of a day (just past midday).
Hope that helps.
Alan."
I need to calculate UPTime from the ExcelI need to know is icon total can calculate time
You have to pay attention to the order when you use subtotal. e.g., subtotal by Market first and then by Customer
I'm not sure if this is a bug in Excel, or just something that was never looked into, but using subtotals more than once, as in the example, does not always produce the desired results. For instance, using the example data, if the Market 'Africa' only has data for the Customer Name 'AIG', then Customer Name 'AIG' will not subtotal for 'Africa', but instead it will subtotal for 'Asia'. Also, in the opposite scenario, if the Market 'Asia' only has data for the Customer name 'Pacific Bell', then 'Pacific Bell' will not subtotal under 'Africa', but instead under 'Asia'. In other words, Excel will only force a subtotal when there is a change in the 'At each change' field. If this field is a sceondary subtotal and it is consecutive between primary subtotals, then excel will wait til the secondary filed has changed before it will force a subtotal, even if this overlaps two primary subtotals