+ Reply to Thread
Results 1 to 13 of 13

Calculate rank in time range.

  1. #1
    Registered User
    Join Date
    10-12-2019
    Location
    india
    MS-Off Ver
    16
    Posts
    62

    Calculate rank in time range.

    Sir,
    I have a data sheet where columns represent:1. player name 2. url & 3. lots of month(Jan-89,mar-90,..........).Table contains lots value in various months for corresponding player name.

    my requirements is arrange 1st rank for month & display in range format as shown in sample sheet(Sheet2).

    note:any blank cell represents player's last value(ex-for particular player if in jan-89 value is 41 & in apr-89 value is 80 then for feb-89,mar-89 value remains its last value that is 41.
    Attached Files Attached Files

  2. #2
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Calculate rank in time range.

    OK; so just to be clear, you're basically looking to track the highest rating, per column, but where the prior "max" persists until such time as it is surpassed - thereby generating your data ranges, and in the case of Dennis Amiss - he surpassed his own rating so his range continues (as one) until Ian Chappell takes over, right?

  3. #3
    Registered User
    Join Date
    10-12-2019
    Location
    india
    MS-Off Ver
    16
    Posts
    62

    Re: Calculate rank in time range.

    Thanks, XLent for your quick reply.

    You are absolutely right.

  4. #4
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Calculate rank in time range.

    OK - see if the attached works for you. The complication is where the same person surpasses their own ranking etc.

    the results are really driven by the below "key":

    =AGGREGATE(15,6,(COLUMN(Sheet1!$D$2:$PW$509)*10^7+(100000-Sheet1!$D$2:$PW$509)+ROW(Sheet1!$D$2:$PW$509)/1000)/(Sheet1!$D$2:$PW$509>N($B2)),1)

    this derives the best ranking, as it changes over time - but in such a way as to also flag where in the matrix this value resides.

    the subsequent calcs are then just used to ensure that where the same player holds the top rating over an extended period, but with different values, they are listed just once.

    above not particularly efficient and assumes XL2010 or later - you state 2016.

    edit: there is a typo on Sheet2!B3 --
    formula should read: =INDEX(Sheet1!$A:$PW,ROUND(MOD($A3,1)*1000,0),ROUND($A3/10^7,0))

    this change won't alter final output given no-one has (as yet) surpassed Sachin Tendulkar, but it will generate a few more results in Columns A:D so extend these down to row 152 (last rating being 18426).
    Attached Files Attached Files
    Last edited by XLent; 11-20-2019 at 06:35 AM.

  5. #5
    Registered User
    Join Date
    10-12-2019
    Location
    india
    MS-Off Ver
    16
    Posts
    62

    Re: Calculate rank in time range.

    Thanks again XLent for your effort but being a newbie in XL it is complicated to me.can u elaborate step by step how to implement it & will be a huge help for me.

  6. #6
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Calculate rank in time range.

    not quite sure which bits - as mentioned in earlier note - the crucial piece is the "key" -- this is logged in Col A on Sheet2 in my prior attachment.

    the "key" is generating a number for every cell in your Sheet1 matrix from D2 (Andy Flower - Jan'71) through to PW509 (Zulqarnain Aug'19)

    the "key" itself is comprised of 3 values:

    [1] column # * 10^7: so Col D (Column # 4) would generate a value of 4000000
    [2] 100000 - score: so a score of 82 would generate a value of 99918 ; we do the subtraction from 100k to ensure that the higher the rating the lower the resulting value
    [3] row number / 1000: so row number 242 would generate a decimal value of 0.242

    the above, which all relate to John Edrich Jan'71 (D242), get combined to generate a single value: 40099918.242

    and as noted you get one of these values for every cell in the matrix

    what we then do is divide these values by a Boolean (True/False)
    the Boolean in this case is whether or not the score, in the given cell within the matrix, is higher than the previous score we logged in our results table
    if the answer is "no" (i.e. not greater than prior) then the "key" value is effectively voided / removed from our array of result values, as irrelevant
    it is ignored because we told our AGGREGATE calc to ignore error values, and in native XL, when coerced, True = 1 and False = 0 -- and if you divide anything by 0 (False) you'll get an error

    so, having applied the above we're left with an array of "key" values - all of which relate to scores that are higher than our previous "highest"

    the key value is comprised in such a way that we know the key we want to return is the smallest, i.e. that which occurred in the earliest month (as driven by the column number), and which relates to the highest rating (remember: component 2 of the key is: 100000-score, so the bigger the rating the smaller the number in the key)

    in the AGGREGATE we use a k value of 1 to ensure that we always pull the smallest value -- so for our first result that is: 40099918.242

    the 4000000 in the above tells us the column number (4000000/1000000 = 4)
    the .242 in the above tells us the row number (.242 * 1000 = 242)

    we can then use the above values to identify the cell on Sheet1 that we're interested in - row 242, column 4 (D) -- and that's John Edrich.

    when we copy down to the next row, we will get a result of 50099832.124

    we can then use the above values to identify the cell on Sheet1 that we're interested in - row 124, column 5 (E) -- and that Dennis Amiss

    Col B:C on Sheet2 are returning the Score & Name for the "key" in Col A, and Col D builds an index of Players which will only increment if the Name changes from Prior row.
    The Index in Col D is then used in the results table to ensure we get one row per Player, per sequence, and we use the Key value related to that index to return the other info like URL.

    Can't explain much more than that, I'm afraid... it's not a trivial calculation.
    Last edited by XLent; 11-20-2019 at 07:46 AM.

  7. #7
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Calculate rank in time range.

    edit: I am so sorry but I only just realised you posted this in the VBA forum, I tend to look at all forums in parallel, and I provided a formula based solution -- would you prefer a coded solution?

    I suspect, if a newbie as you say, whichever route you go by will take a bit of explaining - but the VBA route would be more efficient.

  8. #8
    Registered User
    Join Date
    10-12-2019
    Location
    india
    MS-Off Ver
    16
    Posts
    62

    Re: Calculate rank in time range.

    Thanks again XLent .

  9. #9
    Registered User
    Join Date
    10-12-2019
    Location
    india
    MS-Off Ver
    16
    Posts
    62

    Re: Calculate rank in time range.

    Thanks, XLent for giving your valuable time. U r right. That's why I posted it in VBA section.VBA solution will be easy for me.

  10. #10
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Calculate rank in time range.

    code-wise you could use something pretty trivial like the below - though others could no doubt simplify yet further.

    working version embedded in the attached -- formula version on sheet2, vba output on sheet 3 (invoked via button)

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by XLent; 11-20-2019 at 12:20 PM.

  11. #11
    Registered User
    Join Date
    10-12-2019
    Location
    india
    MS-Off Ver
    16
    Posts
    62

    Re: Calculate rank in time range.

    Thanks, XLent
    Sorry for the late reply. I really appreciate your willingness to help me to solve the problem.
    I insert another sheet(new value) in your customize sheet dibyendu2280_20191120_v2.xlsb‎ & formula works in sheet2 but VBA in sheet3 shows an error.
    I also try separately my new sheet & run VBA which also gives an error. I share my new file & your customize file(in which I insert my new file).
    Attached Files Attached Files

  12. #12
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Calculate rank in time range.

    modified code below to address fact that blanks (in older file) now null strings

    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    10-12-2019
    Location
    india
    MS-Off Ver
    16
    Posts
    62

    Re: Calculate rank in time range.

    Thanks again XLent .
    Now it works perfectively as I want. Thanks, u save me too much time.

+ 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] Calculate hours worked within a time range
    By ilohyou in forum Excel General
    Replies: 5
    Last Post: 11-22-2017, 04:04 PM
  2. Excel Formula to Calculate Time Span Between Different Time Range.
    By omershafiq2012 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-06-2015, 08:28 AM
  3. Replies: 9
    Last Post: 07-13-2014, 11:09 PM
  4. Calculate if Time range appears in an other Time range
    By bajdr47 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 11-25-2013, 02:50 AM
  5. How to calculate time range from 22:00 - 6:00
    By kurk011 in forum Excel General
    Replies: 12
    Last Post: 11-24-2013, 08:57 PM
  6. Calculate block of time for a range of dates
    By Donr in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-24-2013, 06:59 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