Watch the video

How to make "if" in Excel?

Before proceeding to the consideration of the syntax of the "if" function, we define its purpose. From the lessons of the English language it is known that "if" means "if", and from the lessons of informatics "if" (IF) is a logical function of the condition: IF the condition1 is fulfilled, then TRUE, otherwise - FALSE By condition1 is meant some logical expression (for example, comparison), TRUE - means that the condition is true. The result of the condition can be a certain mathematical expression.

For understanding, consider an example of prices in the cinema. It is known that the majority of sessions in the morning hours (say, up to 12 hours) are cheaper than during the day (up to 22 hours), and those, in turn, are cheaper than evening ones (up to 24 hours). Since we have 3 possible conditions (up to 12, up to 20 and up to 24), we have a branching algorithm (nested if loop):

  • IF to 12, then 100 rub., ELSE �
    • If up to 20, then 200 rubles. ��
      • ELSE 250 rub.

The use of this function is useful, first of all, to mathematicians, accountants and financiers (for payroll, calculation of loans, etc.). The easiest way to implement it is in MS Office Excel, because Excel is the most common spreadsheet program in the Windows operating system, and the syntax is the same for all versions (from 97 to 2012).

How to make "if" in Excel?

To use the function, in the free field of the table, click the left mouse button (LMB), put the "=" sign and write "IF". Excel will pop up a hint in the form:

  • IF (log_expression; [value_if_if_status]; [value_if_fold_])

To select this expression, you need to click on it 2 times of the LMB.

The fields described in square brackets [] are optional.

Consider an example:

Suppose we have a warehouse of a household equipment store, and among the goods it is necessary to find TV sets of the Russian assembly worth up to 15,000 rubles.

The table has 4 columns: the column A is the name of the product, B is the country of origin, C is the price per item, D is the mark of the desired item.

In order for our 3 conditions to be fulfilled (TV and Russia and Up to 15,000 rubles), you need to write the following expression in the free field (D2 is the second row of the column D):

  • = IF (AND (A2 = "TV"; B2 = "Russia"; C2 <15000); "+";)

Name

a country

Price, rub

TV Russia 10000 +
fridge Germany 10000 0
kettle Poland 2000 0
fridge Russia 18000 0
TV Russia 160000 0
kettle Russia 1000 0
toaster Hungary 1500 0
TV China 12000 0
fridge Russia 19000 0
kettle China 1800 0
fridge Belorussia 10500 0
toaster China 2000 0
kettle China 2500 0
TV Russia 14800 +
fridge Germany 25000 0

Knowing how the function of the "if" condition works, you can create nested loops to solve more complex problems and multiple checks of conditions.


Date: 09.10.2018, 06:38 / Views: 51585

Related News


Flowers from capron tights
In Japan, came up with a cake recipe. There are only 3 ingredients Surprised
Decoration of glasses for the holiday
How to grow avocado from a bone
A good tone for your holiday