{"id":1102,"date":"2017-08-29T16:28:07","date_gmt":"2017-08-29T21:28:07","guid":{"rendered":"http:\/\/www.iqaccountingsolutions.com\/blog\/?p=1102"},"modified":"2017-08-29T16:28:07","modified_gmt":"2017-08-29T21:28:07","slug":"using-excel-allow-multiple-conditions-using","status":"publish","type":"post","link":"https:\/\/www.iqaccountingsolutions.com\/blog\/using-excel-allow-multiple-conditions-using\/","title":{"rendered":"Using AND() or OR() in Excel to Allow Multiple Conditions When Using IF()"},"content":{"rendered":"<p>Excel&#8217;s <a href=\"http:\/\/www.iqaccountingsolutions.com\/blog\/excels-if-function\/\" target=\"_blank\" rel=\"noopener\">IF() function<\/a>, in case you aren&#8217;t familiar with it, allows you to do one thing if a chosen condition is met, but do something else if that condition is not met. For example, when evaluating test scores you might want to display &#8220;Pass&#8221; if the score is 80% or better, but display &#8220;Fail&#8221; if the score is below 80%.<\/p>\n<p><em>IF<\/em> is an extremely useful function, but it is limited to evaluating one condition. What if you need to evaluate multiple conditions? That&#8217;s where the AND() function and the OR() function come in. <em>AND<\/em> and <em>OR<\/em> are each able to evaluate up to 255 conditions (Excel calls those conditions <em>arguments<\/em>). AND() will give the result &#8220;True&#8221; only if <u>all<\/u> of the conditions\u00a0(arguments) are met, otherwise the result is &#8220;False&#8221;. But OR() will give the result &#8220;True&#8221; if <u>any<\/u> of the conditions are met.<\/p>\n<p>By inserting an <em>AND<\/em> formula or an <em>OR<\/em> formula into the section of an <em>IF<\/em> formula where it would normally evaluate one condition, you can effectively evaluate multiple conditions.<\/p>\n<p>As an example, let&#8217;s build a formula that will calculate a 10% commission only if an invoice has been paid and the margin is at least 20%.<\/p>\n<table border=\"1\" width=\"505\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td><\/td>\n<td nowrap=\"nowrap\">A<\/td>\n<td nowrap=\"nowrap\">B<\/td>\n<td nowrap=\"nowrap\">C<\/td>\n<td nowrap=\"nowrap\">D<\/td>\n<td nowrap=\"nowrap\">E<\/td>\n<td nowrap=\"nowrap\">F<\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td nowrap=\"nowrap\"><strong>Invoice #<\/strong><\/td>\n<td nowrap=\"nowrap\"><strong>Sales Amount<\/strong><\/td>\n<td nowrap=\"nowrap\"><strong>Cost<\/strong><\/td>\n<td nowrap=\"nowrap\"><strong>Margin<\/strong><\/td>\n<td nowrap=\"nowrap\"><strong>Paid?<\/strong><\/td>\n<td nowrap=\"nowrap\"><strong>Commission<\/strong><\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td nowrap=\"nowrap\">1001<\/td>\n<td nowrap=\"nowrap\">332.00<\/td>\n<td nowrap=\"nowrap\">299.00<\/td>\n<td nowrap=\"nowrap\">9.9%<\/td>\n<td nowrap=\"nowrap\">Yes<\/td>\n<td nowrap=\"nowrap\">&#8211;<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td nowrap=\"nowrap\">1002<\/td>\n<td nowrap=\"nowrap\">785.00<\/td>\n<td nowrap=\"nowrap\">550.00<\/td>\n<td nowrap=\"nowrap\">29.9%<\/td>\n<td nowrap=\"nowrap\">Yes<\/td>\n<td nowrap=\"nowrap\">78.50<\/td>\n<\/tr>\n<tr>\n<td>4<\/td>\n<td nowrap=\"nowrap\">1003<\/td>\n<td nowrap=\"nowrap\">6,644.00<\/td>\n<td nowrap=\"nowrap\">4,186.00<\/td>\n<td nowrap=\"nowrap\">37.0%<\/td>\n<td nowrap=\"nowrap\">No<\/td>\n<td nowrap=\"nowrap\">&#8211;<\/td>\n<\/tr>\n<tr>\n<td>5<\/td>\n<td nowrap=\"nowrap\">1004<\/td>\n<td nowrap=\"nowrap\">6,818.00<\/td>\n<td nowrap=\"nowrap\">5,114.00<\/td>\n<td nowrap=\"nowrap\">25.0%<\/td>\n<td nowrap=\"nowrap\">Yes<\/td>\n<td nowrap=\"nowrap\">681.80<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>First let&#8217;s look at two simple examples that we&#8217;ll be able to combine to build the formula we need.<\/p>\n<p>If there was only one condition that needed to be met, such as that the invoice must be paid, then we could use the following formula in cell F2:<\/p>\n<p>=IF(E1=&#8221;Yes&#8221;,B2*0.1,0)<\/p>\n<p>Remember that each &#8220;argument&#8221;, as Excel calls them, is separated by a comma. So, in plain English, the formula says IF cell E1 = Yes, then multiply the contents of cell B2 by 0.1, if not then the commission is 0.<\/p>\n<p>Since we have more than one condition that needs to be met, we want to replace the criteria from the above formula, <em>E1=&#8221;YES&#8221;<\/em> , with a simple formula using the AND function.<\/p>\n<p>If we were to enter the formula <em>=AND(D2&gt;=0.2,E2=&#8221;Yes&#8221;)<\/em> into cell F2 the result would be <em>FALSE<\/em>. The invoice is paid (E2=&#8221;Yes&#8221;) but the margin is less than 20% (<em>D2&gt;=0.2).<\/em> If we had used OR instead of AND with the same arguments the result would be <em>TRUE<\/em> since OR only requires one of the arguments to be met. With either AND or OR you can include up to 255 arguments. Just list all of the arguments (your conditions) between the parenthesis and separate them with commas.<\/p>\n<p>To get the commission formula for this example, all that&#8217;s left to do is to take the first formula <em>=IF(<span style=\"background-color: #ffff00;\">E1=&#8221;Yes&#8221;<\/span>,B2*0.1,0)<\/em> replace the single condition <em>E1=&#8221;Yes&#8221;<\/em> with<em> =AND(D2&gt;=0.2,E2=&#8221;Yes&#8221;)<\/em>. When you put them together looks like this:<\/p>\n<p><em>=IF(<span style=\"background-color: #ffff00;\">AND(D1&gt;=0.2,E1=&#8221;Yes&#8221;)<\/span>,B2*0.1,0)<\/em>.<\/p>\n<p>In plain English that&#8217;s: If cell D1 is greater than or equal to 0.2 <strong>and<\/strong> cell E2 = Yes,then multiply cell B2 by 0.1. If not, then the result is 0.<\/p>\n<p>Remember that you don&#8217;t have to write formulas from scratch. If you go to the <em>Formulas<\/em> tab and click the <em>Insert Function<\/em> button, you can choose a function and it will give you a fill-in-the-blank form to help you get everything entered in the right order.<\/p>\n<p><iframe loading=\"lazy\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/m2-L9iBPrL8?feature=oembed\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Excel&#8217;s IF() function, in case you aren&#8217;t familiar with it, allows you to do one thing if a chosen condition is met, but do something else if that condition is not met. For example, when evaluating test scores you might want to display &#8220;Pass&#8221; if the score is 80% or better, but display &#8220;Fail&#8221; if [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[9,5],"tags":[],"_links":{"self":[{"href":"https:\/\/www.iqaccountingsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1102"}],"collection":[{"href":"https:\/\/www.iqaccountingsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.iqaccountingsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.iqaccountingsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.iqaccountingsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=1102"}],"version-history":[{"count":1,"href":"https:\/\/www.iqaccountingsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1102\/revisions"}],"predecessor-version":[{"id":1103,"href":"https:\/\/www.iqaccountingsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1102\/revisions\/1103"}],"wp:attachment":[{"href":"https:\/\/www.iqaccountingsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=1102"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.iqaccountingsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=1102"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.iqaccountingsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=1102"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}