PART III: WRANGLING DATA
ADD SUBTOTALS TO A DATASET
THÊM CÁC DÒNG CỘNG TỪNG PHẦN VÀP BẢNG DỮ LIỆU
Problem: You have a lengthy report with invoice detail by customer, as shown in Fig. 664. You need to add a subtotal at each change in customer.
Vấn đề: bạn có 1 báo cáo dài dằng dặc như hình 664 với các hoá đơn tính tiền cho khách hàng, bạn muốn có 1 dòng cộng riêng cho mỗi hoá đơn.
Fig. 664
Strategy: A gift from Microsoft in Excel 95, the Automatic Subtotals feature will solve this problem in seconds instead of minutes.
By design, the dataset shown above is optimized for using the Subtotals command. Be sure to read the remaining examples for more details.
1) Start with data in list format. Select a single cell in the dataset.
From the menu, select Data – Subtotals, as shown in Fig. 665.
2. The Subtotals dialog assumes that you want to subtotal by the field in the leftmost column of your data. It also assumes that you want to total the rightmost field. In the present example, shown in Fig. 666, this is correct, so you can choose OK.
Giải pháp: Như 1 quà tặng từ Excel 95, chức năng Auto SubTotals sẽ giải quyết vấn đề này chỉ trong vài giây thay vì nhiều phút. Theo thiết kế, bảng dữ liệu như trên được thiết lập để có thể sử dụng SubTotals. Hãy xem kỹ thí dụ sau đây:
1. bắt đầu với bảng dữ liệu có định dạng List. Chọn 1 ô trong vùng dữ liệu. Chọn Menu – Data – Sub Totals như hình 665
Fig. 665
Fig. 666
In 1-2 seconds, subtotals will be inserted at each change in customer, as shown in Fig. 667.
Chỉ trong vài giây, Các dòng cộng sẽ được chèn vào mỗi lần thay đổi tên khách hàng.
Fig. 667
If you scroll to the end of the dataset, you will notice that Excel added a grand total of all customers, as shown in Fig. 668.
Nếu bạn kéo bảng tính xuống chót dưới, bạn sẽ thấy Excel chèn cả 1 dòng tổng cộng.
Fig. 668
As shown in Fig. 668, the inserted rows are using the somewhat new SUBTOTAL function. This function will total all of the cells in the range except for cells that contain other SUBTOTAL functions
Như hình 668, các dòng được chèn vào sử dụng công thức với hàm SubTotal. Hàm này sẽ tính tổng mọi ô trong cột ngoại trừ các ô có chứa hàm SubTotal ở phía trên.
Additional Details: In order to remove subtotals, select a cell in the dataset. From the menu, select Data – Subtotals. In the Subtotals dia­log, choose the Remove All button, as shown in Fig. 669.
Nói thêm: Để xoá bỏ các dòng cộng này, chọn 1 cell trong vùng dữ liệu, Menu – Data – Sub Totals. Trong hộp thoại hiện ra click nút Remove All.
Fig. 669
Gotcha: This example worked because the data was sorted by Account Number. If the data had been sorted by Invoice Number instead, the result would have been fairly meaningless, as shown in Fig. 670.
Ghi chú: Thí dụ này sử dụng được Sub Total vì đã được sắp theo thứ tự cột Account Number. Nếu dữ liệu sắp xếo thứ tự theo cột Invoice Number, thì kết quả chả có ý nghĩa gì cả như hình 670.
Fig. 670
Summary: The Subtotals command on the data menu quickly auto­mates the monotonous job of adding subtotals. Commands Discussed: Data – Subtotals
Tóm tắt; Lệnh subTotals trong menu Data tự động tính các dòng tổng từng phần và tổng cộng toàn bảng tính dữ liệu.
ADD SUBTOTALS TO A DATASET
THÊM CÁC DÒNG CỘNG TỪNG PHẦN VÀP BẢNG DỮ LIỆU
Problem: You have a lengthy report with invoice detail by customer, as shown in Fig. 664. You need to add a subtotal at each change in customer.
Vấn đề: bạn có 1 báo cáo dài dằng dặc như hình 664 với các hoá đơn tính tiền cho khách hàng, bạn muốn có 1 dòng cộng riêng cho mỗi hoá đơn.

Fig. 664
Strategy: A gift from Microsoft in Excel 95, the Automatic Subtotals feature will solve this problem in seconds instead of minutes.
By design, the dataset shown above is optimized for using the Subtotals command. Be sure to read the remaining examples for more details.
1) Start with data in list format. Select a single cell in the dataset.
From the menu, select Data – Subtotals, as shown in Fig. 665.
2. The Subtotals dialog assumes that you want to subtotal by the field in the leftmost column of your data. It also assumes that you want to total the rightmost field. In the present example, shown in Fig. 666, this is correct, so you can choose OK.
Giải pháp: Như 1 quà tặng từ Excel 95, chức năng Auto SubTotals sẽ giải quyết vấn đề này chỉ trong vài giây thay vì nhiều phút. Theo thiết kế, bảng dữ liệu như trên được thiết lập để có thể sử dụng SubTotals. Hãy xem kỹ thí dụ sau đây:
1. bắt đầu với bảng dữ liệu có định dạng List. Chọn 1 ô trong vùng dữ liệu. Chọn Menu – Data – Sub Totals như hình 665

Fig. 665

Fig. 666
In 1-2 seconds, subtotals will be inserted at each change in customer, as shown in Fig. 667.
Chỉ trong vài giây, Các dòng cộng sẽ được chèn vào mỗi lần thay đổi tên khách hàng.

Fig. 667
If you scroll to the end of the dataset, you will notice that Excel added a grand total of all customers, as shown in Fig. 668.
Nếu bạn kéo bảng tính xuống chót dưới, bạn sẽ thấy Excel chèn cả 1 dòng tổng cộng.

Fig. 668
As shown in Fig. 668, the inserted rows are using the somewhat new SUBTOTAL function. This function will total all of the cells in the range except for cells that contain other SUBTOTAL functions
Như hình 668, các dòng được chèn vào sử dụng công thức với hàm SubTotal. Hàm này sẽ tính tổng mọi ô trong cột ngoại trừ các ô có chứa hàm SubTotal ở phía trên.
Additional Details: In order to remove subtotals, select a cell in the dataset. From the menu, select Data – Subtotals. In the Subtotals dia­log, choose the Remove All button, as shown in Fig. 669.
Nói thêm: Để xoá bỏ các dòng cộng này, chọn 1 cell trong vùng dữ liệu, Menu – Data – Sub Totals. Trong hộp thoại hiện ra click nút Remove All.

Fig. 669
Gotcha: This example worked because the data was sorted by Account Number. If the data had been sorted by Invoice Number instead, the result would have been fairly meaningless, as shown in Fig. 670.
Ghi chú: Thí dụ này sử dụng được Sub Total vì đã được sắp theo thứ tự cột Account Number. Nếu dữ liệu sắp xếo thứ tự theo cột Invoice Number, thì kết quả chả có ý nghĩa gì cả như hình 670.

Fig. 670
Summary: The Subtotals command on the data menu quickly auto­mates the monotonous job of adding subtotals. Commands Discussed: Data – Subtotals
Tóm tắt; Lệnh subTotals trong menu Data tự động tính các dòng tổng từng phần và tổng cộng toàn bảng tính dữ liệu.