+ Reply to Thread
Results 1 to 5 of 5

Nested IF Function

  1. #1
    Registered User
    Join Date
    05-06-2014
    Location
    Illinois
    MS-Off Ver
    Excel 2010
    Posts
    2

    Nested IF Function

    I am very new to working with syntax in Excel 2010. I am used to writing syntax is SPSS for data manipulation. I am trying to figure out how to translate the following SPSS syntax to apply weighted scores to population data in Excel:

    IF (Population<6955) PopScore=0.
    IF (Population>=6955 & Population <13911) PopScore=5.
    IF (Population>=13911 & Population <20866) PopScore=10.
    IF (Population>=20866 & Population <=34777) PopScore=15.
    IF (Population>34777 & Population <=41733) PopScore=10.
    IF (Population>41733 & Population <=48688) PopScore=5.
    IF (Population>48688) PopScore=0.

    Any ideas?

    Thanks!

  2. #2
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.92 (24120731))
    Posts
    9,118

    Re: Nested IF Function

    you can use a nested IF
    IF (Population<6955) PopScore=0.
    IF (Population>=6955 & Population <13911) PopScore=5.
    IF (Population>=13911 & Population <20866) PopScore=10.
    IF (Population>=20866 & Population <=34777) PopScore=15.
    IF (Population>34777 & Population <=41733) PopScore=10.
    IF (Population>41733 & Population <=48688) PopScore=5.
    IF (Population>48688) PopScore=0.
    need to have a cell for
    Population Cell = A2
    Popscore Cell =B2
    so assume those

    You would probably be better of with a lookup BUT as an IF
    in B2 put
    =IF(A2<6955,0,IF(AND(A2>=6955,A2<13911),5,IF(AND(A2>=13911,A2<20866),10,IF(AND(A2>=20866,A2<=34777),15,IF(AND(A2>34777,A2<=41733),10,IF(AND(A2>41733,A2<=48688),5,IF(A2>48688,0,"out of Range")))))))

    I would perhaps change to

    =IF(OR(A2<6955,A2>48688),0,IF(AND(A2>=6955,A2<13911),5,IF(AND(A2>=13911,A2<20866),10,IF(AND(A2>=20866,A2<=34777),15,IF(AND(A2>34777,A2<=41733),10,IF(AND(A2>41733,A2<=48688),5,"out of Range"))))))

    And can probably simplify further
    =IF(OR(A2<6955,A2>48688),0,IF(A2<13911,5,IF(A2<20866,10,IF(A2<=34777,15,IF(A2<=41733,10,IF(A2<=48688,5,"out of Range"))))))

    Just to show you the logic as I progressed , so you can then perhaps apply to other SPSS requirements

    You could also use a lookup table or array
    Wayne
    if my assistance has helped, and only if you wish to , there is an "* Add Reputation" on the left hand side - you can add to my reputation here

    If you have a solution to your thread - Please mark your thread solved do the following: >
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Nested IF Function

    Or maybe this:

    Create a table:

    D
    E
    1
    Lookup Table
    2
    0
    0
    3
    6955
    5
    4
    13911
    10
    5
    20866
    15
    6
    34777
    10
    7
    41733
    5
    8
    48688
    0


    Then use formula
    =VLOOKUP(A2,$D$2:$E$8,2,1)

    A
    B
    C
    D
    E
    1
    Population Score
    Lookup Table
    2
    6500
    0
    0
    0
    3
    6955
    5
    6955
    5
    4
    13911
    10
    13911
    10
    5
    20866
    15
    20866
    15
    6
    34776
    15
    34777
    10
    7
    41733
    5
    41733
    5
    8
    48688
    0
    48688
    0
    9
    34777
    10
    10
    48688
    0
    11
    50000
    0
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  4. #4
    Registered User
    Join Date
    05-06-2014
    Location
    Illinois
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Nested IF Function

    Many thanks!

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Nested IF Function

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

    Also, as a relatively new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] ROUNDUP function nested in IF function--Having problems!
    By whitequeen11 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 04-08-2014, 04:32 PM
  2. [SOLVED] Nested Function With Division - Receiving #VALUE! Function Error
    By DDM64 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-17-2013, 01:16 PM
  3. [SOLVED] Nested AND function within IF function is only addressing logical1 but not logical2
    By betic in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 10-20-2012, 09:17 AM
  4. Replies: 9
    Last Post: 07-02-2012, 07:02 PM
  5. Offset function with nested match function not finding host ss.
    By MKunert in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-21-2006, 06:50 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1