+ Reply to Thread
Results 1 to 16 of 16

Compare two values in two rows and return the higher value for two categories.

  1. #1
    Registered User
    Join Date
    01-30-2013
    Location
    India
    MS-Off Ver
    2013
    Posts
    56

    Compare two values in two rows and return the higher value for two categories.

    Hi Experts,

    Case:
    There are two levels of salesmen in a branch - Tier 1 or Tier 2. In a branch, Tier 2 salesmen cannot have higher pay than a Tier 1 salesmen. Salesmen dummy codes are in the example sheet.

    Solution needed: I looking for a formula which compares the values for tier 1 & 2 and results if a value for tier 2 is higher. E.g. T235 cannot have higher value than T125, it doesn't matter if value for T235 is higher than other Tier codes (Column G in the below screenshot).


    Example.JPG
    Attached Files Attached Files

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,023

    Re: Compare two values in two rows and return the higher value for two categories.

    In G2, copied down:

    =IF(LEFT(E2,2)="T1","OK",IF(F2>F1,"Higher Rate","OK"))
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,731

    Re: Compare two values in two rows and return the higher value for two categories.

    In G2 copied down:

    =IFNA(IF(VLOOKUP(INDEX('Tier Code'!$C$2:$C$14,MATCH(Sheet1!E2,'Tier Code'!$D$2:$D$14,0)),$E$2:$F$27,2,0)<F2,"Higher Rate","OK"),"OK")
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Compare two values in two rows and return the higher value for two categories.

    Hi,

    More explanation is needed. You mention Tier 1 and Tier 2 yet your tier codes are 4 numerics. Do we assume it's the second digit that determines the tierv 1 or 2?

    Why is T235 marked as Higher when the highest Tier 1 code is 192? WHen considering 'higher' are all rows considered as a whole or only each pair of values? i.e. rows 2&3, 4&5 etc? In which case
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by Richard Buttrey; 12-13-2020 at 07:13 AM.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  5. #5
    Registered User
    Join Date
    01-30-2013
    Location
    India
    MS-Off Ver
    2013
    Posts
    56

    Re: Compare two values in two rows and return the higher value for two categories.

    Hi Ali,

    Thanks for the formula, it's working as expected. I'll let you know if I get stuck in it .

  6. #6
    Registered User
    Join Date
    01-30-2013
    Location
    India
    MS-Off Ver
    2013
    Posts
    56

    Re: Compare two values in two rows and return the higher value for two categories.

    Hi Ali,

    Can you further help me on this please?
    I want this formula to check & compare the values of these codes within a branch ID. Every branch uses the same T1 & T2 codes but will have different rates. I am attaching the sample file. Thanks!
    Attached Files Attached Files

  7. #7
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Compare two values in two rows and return the higher value for two categories.

    I don't understand your request. You only show one Branch Z8912.

    Please ensure you include at least two branches in your example data and manually add the results you want to see. Clearly identify which cells are results and which are original data. Make sure the sample data is truly representative. i.e. are different branches always shown in a continuous run of cells or do branches appear between other branches?

  8. #8
    Registered User
    Join Date
    01-30-2013
    Location
    India
    MS-Off Ver
    2013
    Posts
    56

    Re: Compare two values in two rows and return the higher value for two categories.

    Hi Richard,

    Kindly refer the attached spreadsheet "Copy of Example". It has another branch Z1092.
    I've manually added the results in column "G" in the spreadsheet "Copy of Example"
    Note, branches may appear between other branches and not always shown in a continuous run of cells.

    I want the formula to compare the Tier 1 and Tier 2 codes for each branch, return the result in column "G" if the value for Tier 2 code is higher than Tier 1 .
    Attached Files Attached Files

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,731

    Re: Compare two values in two rows and return the higher value for two categories.

    This thread is marked as solved - please remove the tag for now.

  10. #10
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,023

    Re: Compare two values in two rows and return the higher value for two categories.

    can you explain why the answer at Post 2 is incorrect?

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,731

    Re: Compare two values in two rows and return the higher value for two categories.

    How is this different? Using the formula I gave you in post #3 in column H:

    Excel 2016 (Windows) 32 bit
    D
    E
    F
    G
    H
    1
    Branch ID
    Tier Code
    Rate
    Result
    2
    Z8912 T110
    192
    Ok OK
    3
    Z8912 T220
    96
    Ok OK
    4
    Z8912 T115
    177
    Ok OK
    5
    Z8912 T225
    77
    Ok OK
    6
    Z8912 T120
    181
    Ok OK
    7
    Z8912 T230
    55
    Ok OK
    8
    Z8912 T125
    151
    Ok OK
    9
    Z8912 T235
    155
    Higher rate Higher Rate
    10
    Z8912 T130
    159
    Ok OK
    11
    Z8912 T240
    70
    Ok OK
    12
    Z8912 T135
    174
    Ok OK
    13
    Z8912 T245
    97
    Ok OK
    14
    Z8912 T140
    147
    Ok OK
    15
    Z8912 T250
    96
    Ok OK
    16
    Z1092 T110
    143
    Ok OK
    17
    Z1092 T220
    99
    Ok OK
    18
    Z1092 T115
    174
    Ok OK
    19
    Z1092 T225
    187
    Higher rate Higher Rate
    20
    Z1092 T120
    181
    Ok OK
    21
    Z1092 T230
    110
    Ok OK
    22
    Z1092 T125
    158
    Ok OK
    23
    Z1092 T235
    164
    Higher rate Higher Rate
    Sheet: Sheet1

  12. #12
    Registered User
    Join Date
    01-30-2013
    Location
    India
    MS-Off Ver
    2013
    Posts
    56

    Re: Compare two values in two rows and return the higher value for two categories.

    The formula is comparing cell F17 with cell F2, however it should compare it with cell F16 since these values relate to branch ID Z1092
    & not Z8912. The formula should compare the value within a branch ID. Please have a look at the attached spreadsheet "Example_2".
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    01-30-2013
    Location
    India
    MS-Off Ver
    2013
    Posts
    56

    Re: Compare two values in two rows and return the higher value for two categories.

    Formula in post 2 does not give the expected results as it uses 1st two digits to determine tier 1 and 2. This won't work if the codes are changed and the user will again have hunt for a solution. Thanks

  14. #14
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,731

    Re: Compare two values in two rows and return the higher value for two categories.

    Well, none of the solutions offered will work if you keep shifting the goalposts, will they? Do you expect us to be mind readers or to be able to predict the future? If so, I'm afraid you are going to be disappointed.

    Good luck with this.

  15. #15
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,463

    Re: Compare two values in two rows and return the higher value for two categories.

    Try:

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Quang PT

  16. #16
    Registered User
    Join Date
    01-30-2013
    Location
    India
    MS-Off Ver
    2013
    Posts
    56

    Re: Compare two values in two rows and return the higher value for two categories.

    Hi bebo021999,

    Thank you very much for the solution.

+ 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. Return top two categories even when top 2 values are equal
    By Kathleen N in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-03-2019, 04:51 PM
  2. [SOLVED] Compare Two Tables and Return Values Only on Rows that Match the other Table
    By Alienontherun in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 08-27-2018, 06:41 AM
  3. return top 3 values across diff categories
    By rikkyshh in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-29-2016, 05:20 AM
  4. How to compare values and output the higher of the two?
    By a-man in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-25-2014, 03:13 AM
  5. Replies: 4
    Last Post: 02-10-2013, 01:44 AM
  6. Replies: 3
    Last Post: 09-14-2010, 07:25 AM
  7. Replies: 2
    Last Post: 05-31-2010, 03:23 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