SlideShare a Scribd company logo
Chapter 2
Excel Fundamentals
Logical IF Statements, Lookup
Tables, Linear Interpolation
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
The IF Statement
• Logical statements are used to control the
sequence of computations in programs and in
spreadsheet
• MATLAB and Excel both contain IF statements for
adding logical control
• An IF statement tests a condition, and the flow of
calculations is dependent on whether the
condition is true or false
• This is best illustrated with a simple example
Logical Test Example
• Consider taking the absolute value of a number
• How would you instruct Excel to perform this
function (without using the built-in function ABS)
• There are ways to accomplish this without an IF
statement (for example, you can square the
number and then take its square root, which
always returns the positive root), but the most
straightforward method is to use a logical test
Engineering Computation: An Introduction Using MATLAB and Excel
Logical Test Example (cont.)
• In words, you might describe your procedure as:
“If the number is less then zero, then take the negative of
that number, else leave the number as it is”
• This if-then-else logic is widely used in
programming, and can also be used in Excel
• Format of Excel IF statement:
-if(logical_test,value_if_true,value_if_false)
Engineering Computation: An Introduction Using MATLAB and Excel
Excel IF Statement
• The IF statement is a function, with three arguments
• The first argument is the logical test (the condition).
For our example, the logical test will be that the value
of the number considered is less than zero
• The second argument is the action to be taken if the
condition is true (take the negative of the number)
• The third argument is the action to be taken if the
condition is false (report the input number
unchanged)
Engineering Computation: An Introduction Using MATLAB and Excel
Absolute Value Example
• The number to be evaluated is entered into cell A1
• The formula is entered into cell B1
Engineering Computation: An Introduction Using MATLAB and Excel
Nesting IF Statements
• Often, there will be more than two possible outputs for a given
input
• In MATLAB, we use the if-then-else function
• In Excel, we must nest IF statements
• Consider this example: we want to read in a numerical grade and
convert it to a letter grade on a scale of:
– Greater than or equal to 90 = A,
– Greater than or equal to 80 and less than 90 = B
– Greater than or equal to 70 and less than 80 = C
– Greater than or equal to 60 and less than 70 = D
– Less than or equal to 60 = F
Engineering Computation: An Introduction Using MATLAB and Excel

More Related Content

What's hot

Microsoft excel training
Microsoft excel trainingMicrosoft excel training
Microsoft excel trainingMohamed Hassan
 
Spreadsheet Date & Time Functions
Spreadsheet Date & Time FunctionsSpreadsheet Date & Time Functions
Spreadsheet Date & Time Functions
Anjan Mahanta
 
Data Analysis & Visualization using MS. Excel
Data Analysis & Visualization using MS. ExcelData Analysis & Visualization using MS. Excel
Data Analysis & Visualization using MS. Excel
Frehiwot Mulugeta
 
Formulas and functions - By Amresh Tiwari
Formulas and functions - By Amresh TiwariFormulas and functions - By Amresh Tiwari
Formulas and functions - By Amresh Tiwari
Amresh Tiwari
 
If and nested if statements
If and nested if statementsIf and nested if statements
If and nested if statements
Rafael Balderosa
 
Advanced Microsoft Excel
Advanced Microsoft ExcelAdvanced Microsoft Excel
Advanced Microsoft Excel
Eric Metelka
 
Introduction to spreadsheets
Introduction to spreadsheetsIntroduction to spreadsheets
Introduction to spreadsheets
Casey Robertson
 
If Function In Excel
If Function In ExcelIf Function In Excel
If Function In Excel
dinesh takyar
 
Formulas and functions
Formulas and functions Formulas and functions
Formulas and functions
ManishTiwari326
 
Charts and graphs in excel
Charts and graphs in excelCharts and graphs in excel
Charts and graphs in excel
Iqra Nehal
 
Excel training
Excel trainingExcel training
Excel training
Alexandru Gologan
 
Intermediate Excel
Intermediate Excel Intermediate Excel
Intermediate Excel
Lisa De Castro, Ph.D.
 
Intro to Excel Basics: Part I
Intro to Excel Basics: Part IIntro to Excel Basics: Part I
Intro to Excel Basics: Part I
Si Krishan
 
MS EXCEL
MS EXCELMS EXCEL
MS EXCEL
syed_umar
 
Pseudocode
PseudocodePseudocode
Pseudocode
Harsha Madushanka
 
Excel for beginner
Excel for beginnerExcel for beginner
Excel for beginner
Shashank Jain
 
Lesson 15 Using What If Analysis
Lesson 15   Using What If AnalysisLesson 15   Using What If Analysis
Lesson 15 Using What If Analysisguevarra_2000
 
01 microsoft office word 2007 (introduction and parts)
01 microsoft office word 2007 (introduction and parts)01 microsoft office word 2007 (introduction and parts)
01 microsoft office word 2007 (introduction and parts)
benchhood
 

What's hot (20)

Microsoft excel training
Microsoft excel trainingMicrosoft excel training
Microsoft excel training
 
Spreadsheet Date & Time Functions
Spreadsheet Date & Time FunctionsSpreadsheet Date & Time Functions
Spreadsheet Date & Time Functions
 
Data Analysis & Visualization using MS. Excel
Data Analysis & Visualization using MS. ExcelData Analysis & Visualization using MS. Excel
Data Analysis & Visualization using MS. Excel
 
Formulas and functions - By Amresh Tiwari
Formulas and functions - By Amresh TiwariFormulas and functions - By Amresh Tiwari
Formulas and functions - By Amresh Tiwari
 
If and nested if statements
If and nested if statementsIf and nested if statements
If and nested if statements
 
Advanced Microsoft Excel
Advanced Microsoft ExcelAdvanced Microsoft Excel
Advanced Microsoft Excel
 
Introduction to spreadsheets
Introduction to spreadsheetsIntroduction to spreadsheets
Introduction to spreadsheets
 
If Function In Excel
If Function In ExcelIf Function In Excel
If Function In Excel
 
Formulas and functions
Formulas and functions Formulas and functions
Formulas and functions
 
Charts and graphs in excel
Charts and graphs in excelCharts and graphs in excel
Charts and graphs in excel
 
Excel training
Excel trainingExcel training
Excel training
 
Intermediate Excel
Intermediate Excel Intermediate Excel
Intermediate Excel
 
Intro to Excel Basics: Part I
Intro to Excel Basics: Part IIntro to Excel Basics: Part I
Intro to Excel Basics: Part I
 
MS EXCEL
MS EXCELMS EXCEL
MS EXCEL
 
Pseudocode
PseudocodePseudocode
Pseudocode
 
Excel for beginner
Excel for beginnerExcel for beginner
Excel for beginner
 
Excel exercise pdf
Excel exercise pdfExcel exercise pdf
Excel exercise pdf
 
Lesson 15 Using What If Analysis
Lesson 15   Using What If AnalysisLesson 15   Using What If Analysis
Lesson 15 Using What If Analysis
 
01 microsoft office word 2007 (introduction and parts)
01 microsoft office word 2007 (introduction and parts)01 microsoft office word 2007 (introduction and parts)
01 microsoft office word 2007 (introduction and parts)
 
Excel Tutorial
Excel TutorialExcel Tutorial
Excel Tutorial
 

Similar to Excel IF function

Mbd dd
Mbd ddMbd dd
Engineering Numerical Analysis-Introduction.pdf
Engineering Numerical Analysis-Introduction.pdfEngineering Numerical Analysis-Introduction.pdf
Engineering Numerical Analysis-Introduction.pdf
ssuseraae901
 
The 4 Step Excel 2013 Functions Guide
The 4 Step Excel 2013 Functions GuideThe 4 Step Excel 2013 Functions Guide
The 4 Step Excel 2013 Functions Guide
How To Technology
 
Data Structures- Part1 overview and review
Data Structures- Part1 overview and reviewData Structures- Part1 overview and review
Data Structures- Part1 overview and review
Abdullah Al-hazmy
 
Libre Office Calc Lesson 4: Understanding Functions
Libre Office Calc Lesson 4: Understanding FunctionsLibre Office Calc Lesson 4: Understanding Functions
Libre Office Calc Lesson 4: Understanding Functions
Smart Chicago Collaborative
 
classVIII_Coding_Teacher_Presentation.pptx
classVIII_Coding_Teacher_Presentation.pptxclassVIII_Coding_Teacher_Presentation.pptx
classVIII_Coding_Teacher_Presentation.pptx
bhanutickets
 
presentationMs excel
presentationMs excelpresentationMs excel
presentationMs excel
Tanveer Ahmed
 
Excel basics for everyday use-the more advanced stuff
Excel basics for everyday use-the more advanced stuffExcel basics for everyday use-the more advanced stuff
Excel basics for everyday use-the more advanced stuff
Kevin McLogan
 
10 Excel Formulas that will help you in any Job
10 Excel Formulas that will help you in any Job10 Excel Formulas that will help you in any Job
10 Excel Formulas that will help you in any Job
Hitesh Biyani
 
c++ Data Types and Selection
c++ Data Types and Selectionc++ Data Types and Selection
c++ Data Types and Selection
Ahmed Nobi
 
What is algorithm
What is algorithmWhat is algorithm
What is algorithm
lilyMalar1
 
Excel basics for everyday use part three
Excel basics for everyday use part threeExcel basics for everyday use part three
Excel basics for everyday use part threeKevin McLogan
 
excel ppt
excel pptexcel ppt
excel ppt
dd
 
Algorithms and problem solving.pptx
Algorithms and problem solving.pptxAlgorithms and problem solving.pptx
Algorithms and problem solving.pptx
aikomo1
 
3.pdf
3.pdf3.pdf
Intro To C++ - Class 09 - Control Statements: Part 1
Intro To C++ - Class 09 - Control Statements: Part 1Intro To C++ - Class 09 - Control Statements: Part 1
Intro To C++ - Class 09 - Control Statements: Part 1
Blue Elephant Consulting
 
Data structure
Data structureData structure
Data structure
Muhammad Farhan
 
Matlab ch1 (1)
Matlab ch1 (1)Matlab ch1 (1)
Matlab ch1 (1)
mohsinggg
 
ET DAH SI HAN HAN ADIKNYA SI WIDIANTORO RIBUT MULU SAMA ABANG WIDI
ET DAH SI HAN HAN ADIKNYA SI WIDIANTORO RIBUT MULU SAMA ABANG WIDIET DAH SI HAN HAN ADIKNYA SI WIDIANTORO RIBUT MULU SAMA ABANG WIDI
ET DAH SI HAN HAN ADIKNYA SI WIDIANTORO RIBUT MULU SAMA ABANG WIDI
IrlanMalik
 

Similar to Excel IF function (20)

bisection method
bisection methodbisection method
bisection method
 
Mbd dd
Mbd ddMbd dd
Mbd dd
 
Engineering Numerical Analysis-Introduction.pdf
Engineering Numerical Analysis-Introduction.pdfEngineering Numerical Analysis-Introduction.pdf
Engineering Numerical Analysis-Introduction.pdf
 
The 4 Step Excel 2013 Functions Guide
The 4 Step Excel 2013 Functions GuideThe 4 Step Excel 2013 Functions Guide
The 4 Step Excel 2013 Functions Guide
 
Data Structures- Part1 overview and review
Data Structures- Part1 overview and reviewData Structures- Part1 overview and review
Data Structures- Part1 overview and review
 
Libre Office Calc Lesson 4: Understanding Functions
Libre Office Calc Lesson 4: Understanding FunctionsLibre Office Calc Lesson 4: Understanding Functions
Libre Office Calc Lesson 4: Understanding Functions
 
classVIII_Coding_Teacher_Presentation.pptx
classVIII_Coding_Teacher_Presentation.pptxclassVIII_Coding_Teacher_Presentation.pptx
classVIII_Coding_Teacher_Presentation.pptx
 
presentationMs excel
presentationMs excelpresentationMs excel
presentationMs excel
 
Excel basics for everyday use-the more advanced stuff
Excel basics for everyday use-the more advanced stuffExcel basics for everyday use-the more advanced stuff
Excel basics for everyday use-the more advanced stuff
 
10 Excel Formulas that will help you in any Job
10 Excel Formulas that will help you in any Job10 Excel Formulas that will help you in any Job
10 Excel Formulas that will help you in any Job
 
c++ Data Types and Selection
c++ Data Types and Selectionc++ Data Types and Selection
c++ Data Types and Selection
 
What is algorithm
What is algorithmWhat is algorithm
What is algorithm
 
Excel basics for everyday use part three
Excel basics for everyday use part threeExcel basics for everyday use part three
Excel basics for everyday use part three
 
excel ppt
excel pptexcel ppt
excel ppt
 
Algorithms and problem solving.pptx
Algorithms and problem solving.pptxAlgorithms and problem solving.pptx
Algorithms and problem solving.pptx
 
3.pdf
3.pdf3.pdf
3.pdf
 
Intro To C++ - Class 09 - Control Statements: Part 1
Intro To C++ - Class 09 - Control Statements: Part 1Intro To C++ - Class 09 - Control Statements: Part 1
Intro To C++ - Class 09 - Control Statements: Part 1
 
Data structure
Data structureData structure
Data structure
 
Matlab ch1 (1)
Matlab ch1 (1)Matlab ch1 (1)
Matlab ch1 (1)
 
ET DAH SI HAN HAN ADIKNYA SI WIDIANTORO RIBUT MULU SAMA ABANG WIDI
ET DAH SI HAN HAN ADIKNYA SI WIDIANTORO RIBUT MULU SAMA ABANG WIDIET DAH SI HAN HAN ADIKNYA SI WIDIANTORO RIBUT MULU SAMA ABANG WIDI
ET DAH SI HAN HAN ADIKNYA SI WIDIANTORO RIBUT MULU SAMA ABANG WIDI
 

Excel IF function

  • 1. Chapter 2 Excel Fundamentals Logical IF Statements, Lookup Tables, Linear Interpolation Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
  • 2. The IF Statement • Logical statements are used to control the sequence of computations in programs and in spreadsheet • MATLAB and Excel both contain IF statements for adding logical control • An IF statement tests a condition, and the flow of calculations is dependent on whether the condition is true or false • This is best illustrated with a simple example
  • 3. Logical Test Example • Consider taking the absolute value of a number • How would you instruct Excel to perform this function (without using the built-in function ABS) • There are ways to accomplish this without an IF statement (for example, you can square the number and then take its square root, which always returns the positive root), but the most straightforward method is to use a logical test Engineering Computation: An Introduction Using MATLAB and Excel
  • 4. Logical Test Example (cont.) • In words, you might describe your procedure as: “If the number is less then zero, then take the negative of that number, else leave the number as it is” • This if-then-else logic is widely used in programming, and can also be used in Excel • Format of Excel IF statement: -if(logical_test,value_if_true,value_if_false) Engineering Computation: An Introduction Using MATLAB and Excel
  • 5. Excel IF Statement • The IF statement is a function, with three arguments • The first argument is the logical test (the condition). For our example, the logical test will be that the value of the number considered is less than zero • The second argument is the action to be taken if the condition is true (take the negative of the number) • The third argument is the action to be taken if the condition is false (report the input number unchanged) Engineering Computation: An Introduction Using MATLAB and Excel
  • 6. Absolute Value Example • The number to be evaluated is entered into cell A1 • The formula is entered into cell B1 Engineering Computation: An Introduction Using MATLAB and Excel
  • 7. Nesting IF Statements • Often, there will be more than two possible outputs for a given input • In MATLAB, we use the if-then-else function • In Excel, we must nest IF statements • Consider this example: we want to read in a numerical grade and convert it to a letter grade on a scale of: – Greater than or equal to 90 = A, – Greater than or equal to 80 and less than 90 = B – Greater than or equal to 70 and less than 80 = C – Greater than or equal to 60 and less than 70 = D – Less than or equal to 60 = F Engineering Computation: An Introduction Using MATLAB and Excel