Giúp em công thức tính tổng trong kho, ko dùng Countif ạ (1 người xem)

Liên hệ QC

Người dùng đang xem chủ đề này

ThuyTrang79

Thành viên hoạt động
Tham gia
13/2/20
Bài viết
140
Được thích
26
Em chào anh chị !
Giúp hộ em công thức tính tổng sản phẩm theo kho, ko dùng hàm Countif, như ảnh mô tả ạ.
Em cảm ơn nhiều ạ !
1663775720479.png
 

File đính kèm

Dạ em đang dùng 2 CT này,
CT 2a, cùng tính theo điều kiện này, nhưng nếu >=3 thì hiển thị 1, ko đủ điều kiện hiển thị 0
CT 2b, là đang chạy theo đề bài ra KQ đúng KQ cần, nhưng dữ liệu nhiều sẽ nặng máy
Nhờ anh tối ưu giúp em CT theo bài cho nó nhẹ với ạ.
Em cảm ơn anh !
1663821715483.png
 

File đính kèm

=IF(B$2:B18<=1,0,COUNTIF(B$2:B18,B2)), chạy hàng chục ngàn dòng ok.
 
Tôi chưa từng thấy CountIf có liên quan đến auto filter.
Dạ trước em dùng CT này =IF(($B2:$B18<>0)*(COUNTIF($B2:$B18,$B2:$B18)>=3),1,0), nhập CT enter nó tự chạy từ đầu đến cuối dữ liệu ạ, mà nặng máy ạ
Bài đã được tự động gộp:

=IF(B$2:B18<=1,0,COUNTIF(B$2:B18,B2)), chạy hàng chục ngàn dòng ok.
Dạ CT này em thấy chạy nhẹ, mà KQ ra chưa đúng ạ.
 
Lần chỉnh sửa cuối:
Dạ trước em dùng CT này =IF(($B2:$B18<>0)*(COUNTIF($B2:$B18,$B2:$B18)>=3),1,0), nhập CT enter nó tự chạy từ đầu đến cuối dữ liệu ạ, mà nặng máy ạ
Bài đã được tự động gộp:


Dạ CT này em thấy chạy nhẹ, mà KQ ra chưa đúng ạ.
Thử vầy xem sao!?

Mã:
C2=IF(B2>0,TEXT(COUNTIF($B$2:$B$10000,B2),"[>2];;\0"),)
Enter, fill xuống.

Thân
 

File đính kèm

Dạ trước em dùng CT này =IF(($B2:$B18<>0)*(COUNTIF($B2:$B18,$B2:$B18)>=3),1,0), nhập CT enter nó tự chạy từ đầu đến cuối dữ liệu ạ, mà nặng máy ạ
Bài đã được tự động gộp:


Dạ CT này em thấy chạy nhẹ, mà KQ ra chưa đúng ạ.
Kết quả đúng như bạn muốn ở cột C mà.
 
Mình thử DCOUNTA() cũng đặng:

=IF(DCOUNTA(CSDL,B1,G1:G2)<3,0,DCOUNTA(CSDL,B1,G1:G2))​
 
Số kho thực tế chỉ là hữu hạn (trong ví dụ là 5 kho) do đó bạn cần lập danh sách kho và đếm 1 lần thôi.
Trong file mình dùng F1:G6 là danh sách kho và đếm số SP trong kho đó
Sau đó tại C2 bạn dùng VLOOKUP

=VLOOKUP(B2,$F$2:$G$6,2,0)

Nếu có 1 triệu dòng dữ liệu:
Cách này chỉ dùng COUNTIF = 5 lần
Cách cũ bạn dùng 1.000.000 cái COUNTIF CHO 1.000.000 dòng
 

File đính kèm

Số kho thực tế chỉ là hữu hạn (trong ví dụ là 5 kho) do đó bạn cần lập danh sách kho và đếm 1 lần thôi.
. . . . .

Nếu có 1 triệu dòng dữ liệu:
Cách này chỉ dùng COUNTIF = 5 lần
Cách cũ bạn dùng 1.000.000 cái COUNTIF CHO 1.000.000 dòng
Nếu có ô Validation 5 cái kho ý thì . . . sao nữa anh chàng BeBo?
 
Em dùng cách như bác trên nói, countif 5 lần thôi, sau đó dùng vlookup, chủ thớt xem có giúp được chủ thớt không
 

File đính kèm

Mình thử DCOUNTA() cũng đặng:

=IF(DCOUNTA(CSDL,B1,G1:G2)<3,0,DCOUNTA(CSDL,B1,G1:G2))​
Em ko hiểu CT này chạy như nào, em chạy thử ko dc ạ

Thử vầy xem sao!?

Mã:
C2=IF(B2>0,TEXT(COUNTIF($B$2:$B$10000,B2),"[>2];;\0"),)
Enter, fill xuống.

Thân
Vì dữ liệu em là theo cột ko giới hạn, nên CT anh @Phan Thế Hiệp chạy nhanh và nhẹ, ko cần dùng cột phụ, nên CT này OK nhất ạ, em cảm ơn anh !
Mấy nay nhà em có người bệnh nên em ko online trả lời dc ạ,
Em xin cảm ơn anh chị đã nhiệt tình giúp đỡ em, chúc anh chị gặp nhiều may mắn ạ !!!
 
Thử vầy xem sao!?

Mã:
C2=IF(B2>0,TEXT(COUNTIF($B$2:$B$10000,B2),"[>2];;\0"),)
Enter, fill xuống.

Thân
Dạ em CT này cho kết quả dạng text, em dùng tiếp CT khác cho kết quả này bị cho ra kết quả sai, nhờ anh sửa giúp em kết quả hiển thị ko fai là text với ạ, em cảm ơn anh !
 
Dạ em CT này cho kết quả dạng text, em dùng tiếp CT khác cho kết quả này bị cho ra kết quả sai, nhờ anh sửa giúp em kết quả hiển thị ko fai là text với ạ, em cảm ơn anh !
Thêm -- trước If()
C2=--IF(B2>0,TEXT(COUNTIF($B$2:$B$10000,B2),"[>2];;\0"),)

Thân
 
Dạ nhờ anh hướng dẫn cách chạy với ạ !
Support page

DCOUNTA function​


This article describes the formula syntax and usage of the DCOUNTA function in Microsoft Excel.

Description​

Counts the nonblank cells in a field (column) of records in a list or database that match conditions that you specify.
The field argument is optional. If field is omitted, DCOUNTA counts all records in the database that match the criteria.

Syntax​

DCOUNTA(database, field, criteria)
The DCOUNTA function syntax has the following arguments:
  • Database Required. The range of cells that makes up the list or database. A database is a list of related data in which rows of related information are records, and columns of data are fields. The first row of the list contains labels for each column.
  • Field Optional. Indicates which column is used in the function. Enter the column label enclosed between double quotation marks, such as "Age" or "Yield," or a number (without quotation marks) that represents the position of the column within the list: 1 for the first column, 2 for the second column, and so on.
  • Criteria Required. The range of cells that contains the conditions that you specify. You can use any range for the criteria argument, as long as it includes at least one column label and at least one cell below the column label in which you specify a condition for the column.
  • Remarks
  • You can use any range for the criteria argument, as long as it includes at least one column label and at least one cell below the column label for specifying the condition.
    For example, if the range G1:G2 contains the column label Income in G1 and the amount $10,000 in G2, you could define the range as MatchIncome and use that name as the criteria argument in the database functions.
  • Although the criteria range can be located anywhere on the worksheet, do not place the criteria range below the list. If you add more information to the list, the new information is added to the first row below the list. If the row below the list is not blank, Excel cannot add the new information.
  • Make sure that the criteria range does not overlap the list.
  • To perform an operation on an entire column in a database, enter a blank line below the column labels in the criteria range.
 
Support page

DCOUNTA function​


This article describes the formula syntax and usage of the DCOUNTA function in Microsoft Excel.

Description​

Counts the nonblank cells in a field (column) of records in a list or database that match conditions that you specify.
The field argument is optional. If field is omitted, DCOUNTA counts all records in the database that match the criteria.

Syntax​

DCOUNTA(database, field, criteria)
The DCOUNTA function syntax has the following arguments:
  • Database Required. The range of cells that makes up the list or database. A database is a list of related data in which rows of related information are records, and columns of data are fields. The first row of the list contains labels for each column.
  • Field Optional. Indicates which column is used in the function. Enter the column label enclosed between double quotation marks, such as "Age" or "Yield," or a number (without quotation marks) that represents the position of the column within the list: 1 for the first column, 2 for the second column, and so on.
  • Criteria Required. The range of cells that contains the conditions that you specify. You can use any range for the criteria argument, as long as it includes at least one column label and at least one cell below the column label in which you specify a condition for the column.
  • Remarks
  • You can use any range for the criteria argument, as long as it includes at least one column label and at least one cell below the column label for specifying the condition.
    For example, if the range G1:G2 contains the column label Income in G1 and the amount $10,000 in G2, you could define the range as MatchIncome and use that name as the criteria argument in the database functions.
  • Although the criteria range can be located anywhere on the worksheet, do not place the criteria range below the list. If you add more information to the list, the new information is added to the first row below the list. If the row below the list is not blank, Excel cannot add the new information.
  • Make sure that the criteria range does not overlap the list.
  • To perform an operation on an entire column in a database, enter a blank line below the column labels in the criteria range.
Dạ vậy chạy bằng VBA ak anh, tại em ko rành anh thông cảm cho em.
 
Đó là hàm cổ lỗ sỹ của Ecxel mà, trời đất!
→ → → → → → Help
 

Bài viết mới nhất

Back
Top Bottom