Error in formula with OR

Asked

Viewed 257 times

5

Some reason this doesn’t work?

I intend that he counts how many situations exist within one or another criterion.

Both this formula:

=CONTAR.SE.S(E:E;">120";E:E;"<139" OU F:F;">80";F:F;"<89")

Like this:

=CONTAR.SE.S((E:E;">120";E:E;"<139")OU(F:F;">80";F:F;"<89"))

Doesn’t work.

Translating better what I want is this: I want the total value of a table in which the values in column E are between 120 and 139 or in column F the values are between 80 and 89. If this line has both situations as true it will only count one.

Type an if, if condition 1=true then account 1 passes to the next case otherwise checks condition 2 and if this is true account 1 and passes to the next

  • I deleted my answer because I saw that she was not answering your question. However the ideal would be for you to add the information you gave me to your question explaining a little better what your ultimate goal is. If you want I’ll glue here your last comment.

  • Just one detail I ended up repeating the column E in my reply, the right would be =CONTAR.SE.S(E:E;">120";E:E;"<139")+CONTAR.SE.S(F:F;">80";F:F;"<89"), However, I think what you want is for the condition to be made line by line, right? That is, if E1 meets the condition no need to check the condition in F1.

  • Exactly @Math

3 answers

5


Heed: I don’t know if this is due to the Excel version, but in my Excel in Portuguese (version 14.0.7149.5000 32 bits of Office 2010) nay exists a function called CONTAR.SE.S. The function that exists in my Excel is CONT.SES (and so I use it in the example). Still, Assuming your role is with the correct name, the answer is still valid (simply change the function name).

The function CONT.SES, Counting with multiple criteria, allows you to count using multiple criteria and multiple intervals. So, to have the calculation that you want to just do three counts:

  1. Count the values in column E that are within the interest ranges of that column
  2. Count the values in column F that are within the interest ranges of that column
  3. Count the values in both columns within their respective ranges.

If you add up the values of (1) and (2), it will almost always be right, except when the exceptions you mention occur (the values of both columns E and F on a given row are both accepted). These exceptions are accounted for by (3), so just subtract this value from the previous sum.

For example:

=CONT.SES(E:E;">120";E:E;"<139")+CONT.SES(F:F;">80";F:F;"<89")-CONT.SES(E:E;">120";E:E;"<139";F:F;">80";F:F;"<89")

To avoid the values being fixed in the formula, you may want to configure other cells with these values (for example, cells I1, J1, K1 and L1). In that case, make the formula like this:

=CONT.SES(E:E;">"&I1;E:E;"<"&J1)+CONT.SES(F:F;">"&K1;F:F;"<"&L1)-CONT.SES(E:E;">"&I1;E:E;"<"&J1;F:F;">"&K1;F:F;"<"&L1)

Here is an example of a spreadsheet (which you could have provided - would greatly facilitate the life of anyone who would help you), with the result (the cells "In E", "In F" and "In E and F" contain the partial formulas to demonstrate the results on each previously exposed item). The line indicated by the arrow in red is the only one where the conditions are met in both columns.

inserir a descrição da imagem aqui

2

Several answers have already been submitted, but here is a more concise alternative to what you want to get.

=SOMA(SE((E:E>120)*(E:E<139)+(F:F>80)*(F:F<89);1;0))

A detail quite a lot important: When you finish inserting this formula, you need to press CTRL+SHIFT+ENTER. If you don’t, the formula won’t work.

  • Fantastic answer! Deserves more votes (and I would even say that deserves to be the accepted answer! ). : ) Tip: edit the answer to indicate to the reader that it is the use of a matrix formula. It would also be good to indicate some site for further reading on the subject. For example, that: http://gurudoexcel.com/blog/introducao-a-matrixformulas/

  • 1

    @Luizvieira, more logovou update the reply to include your suggestions. Thanks

-2

The syntax of the function OU is wrong. It works like this:

OU(condição1, condição2,...,condiçãoN)

If any of the conditions within the function are true, it returns true.

Behold this article on the use of functions OU and SE together, and read the function documentation OU here

  • Actually that only answers part of the question, what he wants at the end of the day is to use the OU() within the CONTAR.SE.E() because the function in question only uses the E() for your parameters.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.