+ Reply to Thread
Results 1 to 12 of 12

Heat Map

  1. #1
    Registered User
    Join Date
    03-13-2009
    Location
    London, England
    MS-Off Ver
    Excel 2016
    Posts
    98

    Heat Map

    Trying to find the Row(Window) and Column(Percentile) of the highest value in the grid. The value in Cell:AF7 finds the value in the grid(Heat map).

    Once we calculate the Max value in the grid. We set the number of data points Above/Below in Cell:AI7 (This we enter in manually).

    We then go into the Cells in the grid(Heat map), and then calculate the sum of the cells above and below the maximum number (which is returned in Cell AF7) dependant on the number of Data points Above/Below we are looking for. An example of this is done in Column D to M Rows 51 to 61. The sums are calculate of the cells above and below our maximum value in the grid.

    We then want to return the maximum value of the sums of the data points above and below and then return the Percentile and Window Value.

    As an example. Our max value on the heat map is 35.30026 and we want 2 Data points Above/Below. Then the maximum sum is 39.12358. Thus the percentile is 0.62 and the Window is 28.
    Attached Files Attached Files

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Heat Map

    So are you having to find every instance of the Max value, look above & below each, comparing the output ? Presumably you don't always have 4 instances of the MAX value, and not all instances are necessarily adjacent to each other?

  3. #3
    Registered User
    Join Date
    03-13-2009
    Location
    London, England
    MS-Off Ver
    Excel 2016
    Posts
    98

    Re: Heat Map

    Correct! The values in the sheet are returns of a company, based on a percentile and window strategy.

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Heat Map

    I think given the likely complexity you will face you will be best served utilising a UDF... now I had come up with this:

    Please Login or Register  to view this content.
    However I am encountering issues running the Find against your values which I suspect is down to the levels of precision at play in the matrix ... for ex. if I call the function directly from within VBA (to test) and alter the code such that I look for the Max value rounded to 4 decimals (as per your formatting in the matrix) it works, however, the same does not work when called directly from a cell. No doubt I'm missing / overlooking something obvious.

    I will ask some others to review / resolve.

  5. #5
    Registered User
    Join Date
    03-13-2009
    Location
    London, England
    MS-Off Ver
    Excel 2016
    Posts
    98

    Re: Heat Map

    How would I put this into the excel sheet? Since I dont know what rngMatric range etc are. Not good at all with this yet!

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Heat Map

    Hold off for time being as it's not working - I think I'm doing something stupid (more so than normal).

    Essentially UDF's are customised Functions, they are generally stored within the file in which they are used - in VBA Modules... they are then "called" from a cell... eg

    =MAXPW(D11:AC35,AF7,AI7,"P")

    so the above runs the function MAXPW looking for the MAX value (AF7) in the Matrix of values (D11:AC35), once found it will use the number of data points as set in AI7 to establish the sum of data points in/around the max value... it will compare each range it finds (ie one range for each instance of the MAX) ... it will then return either the Percentile or Window associated with the Max range pending whether you say you want the P(ercentile) or W(indow) - as set by the final parameter in the function.

  7. #7
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Heat Map

    DO,
    You can't use FindNext in a UDF. (In older versions of Excel IIRC, you can't even use Find) You may be better served loading the data into an array and looping through that?
    Remember what the dormouse said
    Feed your head

  8. #8
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Heat Map

    No doubt I'm missing / overlooking something obvious.
    Why did I not know that ?
    (perhaps best not to answer...)

    What is the advantage to loading the range into an Array for processing as opposed just iterating the Range direct ?

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Heat Map

    But you can use Find instead of FindNext within the loop.
    Entia non sunt multiplicanda sine necessitate

  10. #10
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Heat Map

    OK so after making myself out to be a complete idiot (again) here is a revised version which iterates the matrix...

    Please Login or Register  to view this content.
    The above would sit within a Module... per your model and example:

    AI9: =MAXPW($D$11:$AC$35,$AF$7,$AI$7,$AH9)
    copied to AI10

  11. #11
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Heat Map

    Quote Originally Posted by DonkeyOte View Post
    What is the advantage to loading the range into an Array for processing as opposed just iterating the Range direct ?
    Quicker than reading cells one by one.

  12. #12
    Registered User
    Join Date
    03-13-2009
    Location
    London, England
    MS-Off Ver
    Excel 2016
    Posts
    98

    Re: Heat Map

    Thanks for the effort! Works perfect

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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