How Excel uses the "subtract" statistic

Source: Internet
Author: User

For example: Column A in the table below shows the number of overtime work per day for the company, requiring that in column B, if there are more than 3 consecutive overtime, the last block of each paragraph records the subtotal number of days.

The problem is that the number of consecutive overtime days in column A is over 3, and there is no rule at all. Therefore, it is difficult to construct the formula by automatic statistics in column B. Commonly used functions Countif although the count is expert, but in the face of irregular data, it is also silly, and the lookup function is strong enough, but by it to complete the task, you also come out in a cold sweat. It seems to have to be self-reliant and cleverly constructed a formula to solve.

To do this, we simply position the cursor to the B2 cell, and then enter the following formula in the formula box:

=if (OR (a2<=3,a3>3), "", COUNTIF (A$2:A2, ">3")-sum (B$1:B1))

After the formula is entered, drag the fill handle in the lower-right corner of the B2 to the last cell in column B so that the number of qualifying days is automatically counted and filled out.

For ease of understanding, here are some explanations of the formula:

if (a2<=3,a3>3), the paragraph: If column A is the current row <=3 or the next row is greater than 3, the formula returns null and the current cell in column B is not filled in.

"COUNTIF (A$2:A2, >3)-sum (B$1:B2)" section: Use the COUNTIF function to count the number of numbers greater than 3 before the current row in column A, and then subtract the results from column B to get the number of qualifying days in the most recent paragraph. It is important to note that the guided area is referenced in a way that uses the $ symbol.

Not afraid of irregular, afraid of no good formula. A good formula can solve a big problem. Computer Tutorials

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.