+ Reply to Thread
Results 1 to 8 of 8

Formula to Compare A Value Against 2 Others

  1. #1
    Registered User
    Join Date
    01-07-2021
    Location
    Turkey
    MS-Off Ver
    MS Office 2016
    Posts
    5

    Formula to Compare A Value Against 2 Others

    Hello,

    Let's assume that we have a certain value in A1 which is the positive integer "x".

    We also have certain other positive integers in cells A20, A21, and A22 which are "a", "b" and "c" respectively. a, b and c are in ascending order.

    I need to print the outcome of the comparison of x to these numbers, into the cell A30.

    The rules I require are:

    if c > x > b, A30 = a
    if x > c, A30 = 0
    if X < b, A30 = x

    Would you help me with constructing the formula please?

    Thanks in advance.
    Last edited by FightCat; 01-07-2021 at 09:43 AM.

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,718

    Re: Formula to Compare A Value Against 2 Others

    Put this formula in A30:

    =IF(A1<A21,A1,IF(A1<A22,A20,0))

    Hope this helps.

    Pete

  3. #3
    Registered User
    Join Date
    01-07-2021
    Location
    Turkey
    MS-Off Ver
    MS Office 2016
    Posts
    5

    Re: Formula to Compare A Value Against 2 Others

    Hello,

    Just fixed the semicolons needed and it yielded correct results PLUS I got to learn the logic behind it.

    =EĞER(A1<A21; A1; EĞER(A1<A22; A20; 0))
    ("eğer" = "if" in Turkish)

    Thank you very much.

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,718

    Re: Formula to Compare A Value Against 2 Others

    You're welcome, and thanks for the rep.

    If that takes care of your original question, please take a moment to select Thread Tools from the menu above and to the right of your first post in this thread, and mark the thread as SOLVED.

    Pete

  5. #5
    Registered User
    Join Date
    01-07-2021
    Location
    Turkey
    MS-Off Ver
    MS Office 2016
    Posts
    5

    Re: Formula to Compare A Value Against 2 Others

    Hello,

    May I add one more condition to the rule above or would it be too much for the formula to handle?

    Let's add one more value to the set of positive integers our initial "x" is compared to.

    "z" is the lower threshold of this set of numbers which was entered in the cell A19. So the final set would be in this order: z < a < b < c (cell-wise: A19 < A20 < A21 < A22)

    The new condition is: When "x" is lower than "z", type "x" in A30 as the output AND type "x" (as a string) in cell A40.

    Would that be too much of a cascade for the formula?

    Thanks.

  6. #6
    Registered User
    Join Date
    01-07-2021
    Location
    Turkey
    MS-Off Ver
    MS Office 2016
    Posts
    5

    Re: Formula to Compare A Value Against 2 Others

    Would that work? I looked up a few things to come up with a solution myself:

    =EĞER(A1<A21; EĞER(A1<A19; A1, AND(TYPE(A40,"x"); A1); EĞER(A1<A22; A20; 0))

  7. #7
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,718

    Re: Formula to Compare A Value Against 2 Others

    You can't have a formula in A30 which "pushes" a value to A40 - you would need a formula in A40 instead, as well as the formula in A30. I would suggest the following in the cells stated:

    A30: =IF(A1<A19,"x",IF(A1<A21,A1,IF(A1<A22,A20,0)))

    A40: =IF(A1<A19,"x","")

    Obviously, change the commas ( , ) to semicolons ( ; ) and use EĞER instead of IF.

    Hope this helps.

    Pete

  8. #8
    Registered User
    Join Date
    01-07-2021
    Location
    Turkey
    MS-Off Ver
    MS Office 2016
    Posts
    5

    Re: Formula to Compare A Value Against 2 Others

    Thank you!

+ 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] date compare formula
    By Fawkes_ in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-08-2017, 02:08 PM
  2. [SOLVED] Formula to compare
    By rizmomin in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-29-2015, 02:41 PM
  3. Help need with compare formula
    By ianhearn in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 05-15-2014, 07:54 AM
  4. I need a for formula to compare data in same row and Put 1
    By Infoway123 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-29-2013, 12:44 PM
  5. A compare formula
    By zhshqzyc in forum Excel General
    Replies: 3
    Last Post: 03-17-2011, 09:48 PM
  6. Help with compare formula
    By CazMan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-08-2006, 01:47 AM
  7. compare formula
    By rbmcclen in forum Excel General
    Replies: 1
    Last Post: 08-11-2006, 02:00 PM

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