The “less than or equal to” operator (<=) in Excel is a fundamental tool for comparing values and performing logical operations within your formulas. This operator checks if a value is less than or equal to another and returns TRUE or FALSE based on the outcome. It’s super useful when combined with functions like IF, SUMIF, and COUNTIF for more complex calculations.
Using <= with Functions
In Excel, you’ll often use logical operators like <= inside functions to create conditional calculations. This allows you to develop dynamic formulas that react to your data.
Using <= with the IF Function
The IF function works perfectly with the <= operator to perform tests and return specific values. Imagine you have a list of student scores and want to classify each student as “Pass” or “Fail” based on a passing score of 50.
To check the score in cell B2, use this formula in cell C2:
=IF(B2<=50,"Fail","Pass")
This formula checks if the value in B2 is less than or equal to 50. If TRUE, it returns “Fail”; otherwise, it returns “Pass”.
Copy this formula down the column to evaluate all the scores in your list.
Another example: You need to calculate delivery charges based on the cost of an item. If an item is $150 or less, a $20 charge is added; otherwise, a $10 charge is applied. Here’s the formula:
=IF(B2<=150, B2+$D$2, B2+$D$3)
Here, $D$2
and $D$3
are absolute references to the cells that hold the different delivery charges. The formula adds the correct delivery charge to the price in B2, based on the condition.
Using <= with the SUMIF Function
The SUMIF function adds values that meet specific criteria. Using the <= operator within the criteria, you can sum all values that are less than or equal to a particular number or date.
For example, to sum all sales on or before January 1, 2020, use this formula:
=SUMIF(A2:A16,"<=1/1/2020",C2:C16)
This formula checks the dates in the range A2:A16 and adds up the corresponding sales in C2:C16 where the date matches the given condition.
Using <= with the COUNTIF Function
The COUNTIF function counts cells that meet a specific condition. By using <=, you can count how many values are less than or equal to a certain number.
To count the number of sales equal to or less than 1000 in the range C2:C16, the formula is:
=COUNTIF(C2:C16,"<=1000")
This will give you the count of cells where the sales amount is 1000 or less.
If your criterion value is in a cell, say F3, you can refer to it in the formula:
=COUNTIF(C2:C16,"<="&F3)
Comparing Numbers with <=
Comparing numbers with the <= operator is very straightforward. It lets you see if a numeric value is less than or equal to another.
For example, to compare the values in cells A2 and B2, use the formula:
=A2<=B2
This returns TRUE if A2 is less than or equal to B2; otherwise, it returns FALSE.
You can also use the <= operator in more complex mathematical calculations with other operators and functions:
=(A4>B3)+(A1*B5)+(B2/2)+(B6<=A3)
In this formula, logical statements like (A4>B3) and (B6<=A3) become 1 if TRUE and 0 if FALSE, which then contribute to the final calculation.
Comparing Dates with <=
You can also compare dates using the <= operator in Excel. Because Excel saves dates as serial numbers, you can do logical operations directly with date values.
For instance, to see if the date in A2 is less than or equal to the date in B2, use:
=A2<=B2
This formula will compare the serial numbers of the dates and return TRUE if the condition is met.
When using dates directly in formulas, be careful since Excel may misinterpret them. To be precise, use the DATEVALUE
function when comparing to a specific date:
=A1<=DATEVALUE("5-12-2020")
This converts the date text string into a serial number that Excel can understand as a date.
Comparing Text Values with <=
The <= operator can also compare text strings in Excel. Excel evaluates alphabetical order by checking the Unicode value of each character. Keep in mind that logical operators are not case-sensitive, so “A” and “a” are equal.
To compare text in cells A3 and B3, use:
=A3<=B3
If both cells have the same text, this formula returns TRUE.
You can also compare text literals directly:
="Ant"<="ant"
This formula returns TRUE because Excel does not consider case differences.
Example 1: Comparing “Ant” and “Elephant”
Even though “Ant” and “Elephant” are different, Excel will compare them character by character. “A” is less than “E”, so the formula
=A3<=B3
returns TRUE.
Example 2: Comparing “Apple” and “April”
If the first letters match, Excel moves on to the next. In this case, “p” is not less than “p”, so the comparison moves forward. Eventually, it finds that “l” is less than “r”, so the formula
=A3<=B3
returns FALSE.
Using <= Operator in Excel Conditional Formatting
You can use the <= operator in conditional formatting to highlight cells that meet certain criteria. For instance, to highlight sales amounts that are less than or equal to 2000, follow these steps:
- Select the range C2:C16.
- Go to the Home tab, click on Conditional Formatting, and select New Rule.
- In the New Formatting Rule dialog box, choose Use a formula to determine which cells to format. Enter the formula:
=C2<=2000
- Click Format to set the formatting. Select your formatting options and then click OK.
- Click OK again to apply the rule. Cells with sales amounts less than or equal to 2000 will now be highlighted.
The <= operator is a powerful tool in Excel that helps you perform logical comparisons and conditional calculations across all sorts of data.