SlideShare a Scribd company logo
1 of 7
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

Applications of analytic functions and vector calculus
Applications of analytic functions and vector calculusApplications of analytic functions and vector calculus
Applications of analytic functions and vector calculus
Poojith Chowdhary
 
What is analytic functions
What is analytic functionsWhat is analytic functions
What is analytic functions
Tarun Gehlot
 

What's hot (20)

What is algorithm
What is algorithmWhat is algorithm
What is algorithm
 
Object oriented programming15 control structures relational operators
Object oriented programming15 control structures relational operatorsObject oriented programming15 control structures relational operators
Object oriented programming15 control structures relational operators
 
Operators in c
Operators in cOperators in c
Operators in c
 
Fundamental of Algorithms
Fundamental of Algorithms Fundamental of Algorithms
Fundamental of Algorithms
 
Applications of analytic functions and vector calculus
Applications of analytic functions and vector calculusApplications of analytic functions and vector calculus
Applications of analytic functions and vector calculus
 
OPERATORS OF C++
OPERATORS OF C++OPERATORS OF C++
OPERATORS OF C++
 
What is analytic functions
What is analytic functionsWhat is analytic functions
What is analytic functions
 
Operators and expressons
Operators and expressonsOperators and expressons
Operators and expressons
 
Arithmetic operator
Arithmetic operatorArithmetic operator
Arithmetic operator
 
Lecture Note-2: Performance analysis of Algorithms
Lecture Note-2: Performance analysis of AlgorithmsLecture Note-2: Performance analysis of Algorithms
Lecture Note-2: Performance analysis of Algorithms
 
Presentation
PresentationPresentation
Presentation
 
c# operators
c# operatorsc# operators
c# operators
 
Functional programming f#
Functional programming   f# Functional programming   f#
Functional programming f#
 
Interpretable ML
Interpretable MLInterpretable ML
Interpretable ML
 
Mathematical and logical operators
Mathematical and logical operatorsMathematical and logical operators
Mathematical and logical operators
 
Flowchart design for algorithms
Flowchart design for algorithmsFlowchart design for algorithms
Flowchart design for algorithms
 
Use Of Calculus In Programming
Use Of Calculus In ProgrammingUse Of Calculus In Programming
Use Of Calculus In Programming
 
Intro to Functional Programming @ Scala Montreal
Intro to Functional Programming @ Scala MontrealIntro to Functional Programming @ Scala Montreal
Intro to Functional Programming @ Scala Montreal
 
Algorithm
AlgorithmAlgorithm
Algorithm
 
Operators
OperatorsOperators
Operators
 

Viewers also liked

Harmony in the Workplace Participant Guide.5.27.15
Harmony in the Workplace Participant Guide.5.27.15Harmony in the Workplace Participant Guide.5.27.15
Harmony in the Workplace Participant Guide.5.27.15
Frederick E. Hairston, Jr.
 
Patient engagement-is-all-about-accessibility-accountability-and-assurance
Patient engagement-is-all-about-accessibility-accountability-and-assurancePatient engagement-is-all-about-accessibility-accountability-and-assurance
Patient engagement-is-all-about-accessibility-accountability-and-assurance
Optimize Medical Practice
 
Daily Scorecard can transform Medical Practices
Daily Scorecard can transform Medical PracticesDaily Scorecard can transform Medical Practices
Daily Scorecard can transform Medical Practices
Optimize Medical Practice
 

Viewers also liked (10)

Harmony in the Workplace Participant Guide.5.27.15
Harmony in the Workplace Participant Guide.5.27.15Harmony in the Workplace Participant Guide.5.27.15
Harmony in the Workplace Participant Guide.5.27.15
 
Persentasi instrumen slide share
Persentasi instrumen slide sharePersentasi instrumen slide share
Persentasi instrumen slide share
 
Slideshare Pondoc
Slideshare PondocSlideshare Pondoc
Slideshare Pondoc
 
Patient engagement-is-all-about-accessibility-accountability-and-assurance
Patient engagement-is-all-about-accessibility-accountability-and-assurancePatient engagement-is-all-about-accessibility-accountability-and-assurance
Patient engagement-is-all-about-accessibility-accountability-and-assurance
 
JumpStart.LinkedIn.3.9.16 (Remote)
JumpStart.LinkedIn.3.9.16 (Remote)JumpStart.LinkedIn.3.9.16 (Remote)
JumpStart.LinkedIn.3.9.16 (Remote)
 
img-321105156
img-321105156img-321105156
img-321105156
 
Pg intro
Pg intro Pg intro
Pg intro
 
Daily Scorecard can transform Medical Practices
Daily Scorecard can transform Medical PracticesDaily Scorecard can transform Medical Practices
Daily Scorecard can transform Medical Practices
 
Presentasi jembatan otomatis
Presentasi jembatan otomatisPresentasi jembatan otomatis
Presentasi jembatan otomatis
 
Enigma Club Dj's Official Proposal.
Enigma Club Dj's Official Proposal.Enigma Club Dj's Official Proposal.
Enigma Club Dj's Official Proposal.
 

Similar to Excel IF

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
Kevin McLogan
 
03 Excel formulas and functions
03 Excel formulas and functions03 Excel formulas and functions
03 Excel formulas and functions
Buffalo Seminary
 
excel ppt
excel pptexcel ppt
excel ppt
dd
 

Similar to Excel IF (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
 
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
 
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
 
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
 
03 Excel formulas and functions
03 Excel formulas and functions03 Excel formulas and functions
03 Excel formulas and functions
 
Lec 2 algorithms efficiency complexity
Lec 2 algorithms efficiency  complexityLec 2 algorithms efficiency  complexity
Lec 2 algorithms efficiency complexity
 
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)
 
Algorithm.pptx
Algorithm.pptxAlgorithm.pptx
Algorithm.pptx
 
Algorithm.pptx
Algorithm.pptxAlgorithm.pptx
Algorithm.pptx
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 

Excel IF

  • 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