• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Trouble with Nested IF (should I use AND and/or OR?)|General Excel Questions & Answers|Excel Forum|My Online Training Hub

You are here: Home / Trouble with Nested IF (should I use AND and/or OR?)|General Excel Questions & Answers|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumGeneral Excel Questions & Answe…Trouble with Nested IF (should I us…
sp_PrintTopic sp_TopicIcon
Trouble with Nested IF (should I use AND and/or OR?)
Avatar
Rob Bruce

Active Member
Members
Level 0
Forum Posts: 5
Member Since:
December 11, 2021
sp_UserOfflineSmall Offline
1
December 11, 2021 - 11:17 am
sp_Permalink sp_Print

Hi all, having an issue with getting the result I want based on several criteria.  I'm sure one of your learned selves will be able to solve it quickly however I've been scratching my head for some time to make it work.  I'm only using IF statements, but wonder if I need to use AND and/or OR statements instead.  Had a try with those as well but can't get it to work properly.

Below is what's in the spreadsheet attached.  As per the examples, it works fine when all 3 criteria are entered, however, doesn't provide the result when it's missing either criteria 1 or criteria 2.

 

Thanks in advance.

  Criteria 1 Criteria 2 Criteria 3 I want to use this figure Current Formula Result Formula Text
Outcome 1 1 2 3 3 3 =IF(C13<=0,0,(IF(D13<=0,C13,(IF(E13<=0,D13,E13)))))
Outcome 2 1   3 3 1 =IF(C14<=0,0,(IF(D14<=0,C14,(IF(E14<=0,D14,E14)))))
Outcome 3   2 3 3 0 =IF(C15<=0,0,(IF(D15<=0,C15,(IF(E15<=0,D15,E15)))))
Outcome 4   2   2 0 =IF(C16<=0,0,(IF(D16<=0,C16,(IF(E16<=0,D16,E16)))))
Outcome 5     3 3 0 =IF(C17<=0,0,(IF(D17<=0,C17,(IF(E17<=0,D17,E17)))))
sp_AnswersTopicSeeAnswer See Answer
Avatar
Anders Sehlstedt
Eskilstuna, Sweden

VIP
Members


Trusted Members
Level 3
Forum Posts: 871
Member Since:
December 7, 2016
sp_UserOfflineSmall Offline
2
December 11, 2021 - 6:13 pm
sp_Permalink sp_Print

Hello Rob,

It seems to me that you want the highest number for each row, so for that you only need the MAX function.

The reason to why you get the results you get is because Excel returns a zero to blank cells when you check what number value it has. You can for example check this with =ISNUMBER(A1), assuming that A1 is blank. The result will be FALSE. But if you write =A1=0 you will get TRUE.

But in this scenario I don’t see why you need to use nested IFS.

Br,
Anders

Avatar
Rob Bruce

Active Member
Members
Level 0
Forum Posts: 5
Member Since:
December 11, 2021
sp_UserOfflineSmall Offline
3
December 11, 2021 - 10:50 pm
sp_Permalink sp_Print

Thanks Anders.  Sorry, the example didn't make it clear.  It's not a max result I'm after, it's whichever is the later result I want to display.

For example, criteria 1 could be 100, 2 could be 65 and I'd want 65 to be the result.

Similarly, if criteria 1 is 40, 2 is 50 and 3 is 45 then I'd want 45 to be the result.  If, in this 40/50/45 example, that it was now 0/50/45 then the formula would incorrectly provide a 0 result.

I changed the formula to the below using your ISNUMBER example and it now seems to provide me with the correct result, I'm just not sure it's strictly 100% correct.  Any suggestions to tidy it up?

=IF(ISNUMBER(C13=0),0,(IF(ISNUMBER(D13=0),C13,(IF(E13<=0,D13,E13)))))

Avatar
Anders Sehlstedt
Eskilstuna, Sweden

VIP
Members


Trusted Members
Level 3
Forum Posts: 871
Member Since:
December 7, 2016
sp_UserOfflineSmall Offline
4
December 12, 2021 - 8:06 am
sp_Permalink sp_Print

Hello Rob,

Your formula will always evaluate to FALSE in regards to the ISNUMBER checks, simply because the equal sign makes it to fail. You have however made it to work in a cumbersome way, but it does give correct values until you only have a number in column C and leave columns D and E empty.

Below is an alternative nested IF formula which seems to work.

=IF(ISNUMBER(E3)=TRUE,E3,
IF(ISNUMBER(D3)=TRUE,D3,
IF(ISNUMBER(C3)=TRUE,C3,0)))

Added a modified version of your sample file showing the alternative formula and yours, so you can see what works.

Br,
Anders

sp_AnswersTopicAnswer
Answers Post
Avatar
Rob Bruce

Active Member
Members
Level 0
Forum Posts: 5
Member Since:
December 11, 2021
sp_UserOfflineSmall Offline
5
December 12, 2021 - 7:32 pm
sp_Permalink sp_Print

Thanks Anders, much appreciated.

Avatar
Velouria
London or thereabouts
Moderator
Members


Trusted Members

Moderators
Level 4
Forum Posts: 627
Member Since:
November 1, 2018
sp_UserOfflineSmall Offline
6
December 13, 2021 - 7:58 pm
sp_Permalink sp_Print

To get the last number, you could also use:

=LOOKUP(1E+100,C3:E3)

The following users say thank you to Velouria for this useful post:

Anders Sehlstedt
sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Brian Pham, Riny van Eekelen
Guest(s) 9
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 871
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
Jessica Stewart: 205
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
stuart burge
Bruce Tang Nian
Scot C
Othman AL MUTAIRI
Misael Gutierrez Sr.
Attif Ihsan
Kieran Fee
Murat Hasanoglu
Brett Dryland
Saeed Aldousari
Forum Stats:
Groups: 3
Forums: 24
Topics: 6223
Posts: 27295

 

Member Stats:
Guest Posters: 49
Members: 31920
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.