Forum Discussion

David Attard's avatar
David Attard
Copper Contributor
Sep 04, 2017
Solved

Using Excel lookup based on multiple criteria

Hi All,

Please help me as i am frustrated to the point of giving up.

 

I am trying to use excel to lookup a value, based on that value look with another cell and find the highest number associated to that said value, and output the value froma a cell adjacent to it.

 

Eg.

WeekDateWorkoutSetRepKGTotal
Week 14/09/2017Dead lift11220240
Week 14/09/2017One Arm Floor Press11215180
Week 14/09/2017Barbell Shrug (Behind Back)1128.75105
Week 14/09/2017Medow Row11220240
Week 14/09/2017Skull Crushers11210120
Week 14/09/2017Side bends11220240
Week 14/09/2017Lying Doubble Leg Raise11200
Week 14/09/2017Lunges11200
Week 14/09/2017Straight Arm Pulldown11210.2122.4
Week 14/09/2017Face Pull1613.681.6
Week 14/09/2017Machine Rope Hammer Curls1126.881.6
Week 14/09/2017Reverse Cable Side Bends11210.2122.4
Week 14/09/2017Squats11225300
Week 14/09/2017Single arm Lat Pulldowns11110.2112.2
Week 14/09/2017Bench Press (Supinated Grip)111666
Week 14/09/2017Landmine Later Raise1128.75105
Week 14/09/2017Incline Tricep Extension1800
Week 14/09/2017Incline Dumbell Curls11210120
Week 14/09/2017Pushups11210120
Week 24/09/2017Dead lift11050500

 

Cell 1: Define a lookup value: E.g `Dead Lift` 

Cell 2: Based on the lookup value `Dead Lift` find the heaviest lift and return the KG.

Cell 3: Based on the heaviest lift KG return the adjacent `Rep` cell

Cell 4: Based on the lookup value `Dead lift` find the second heviest lift and return the KG

Cell 5: Based on the second heviest lift  in KG return the adjacent `Rep` cell. 

 

 

I feel like this should be easy but i am having to much trouble trying to do this. 

 

I have attached the spreadsheet for additonal reference.

 

Thanks in advance.

  • Hi David,

     

    please see attached for the sample solution. For the second highest rep I used the following formula (array entered):

    {=INDEX($E$2:$E$500,LARGE(IF($C$2:$C$500=K1,ROW($C$2:$C$500)-ROW(INDEX($C$2:$C$500,1,1))+1),2))}

    Similarily, for the second highest weight I used

    {=INDEX($F$2:$F$500,LARGE(IF($C$2:$C$500=K1,ROW($C$2:$C$500)-ROW(INDEX($C$2:$C$500,1,1))+1),2))}

     

    Hope this helps

    Regards

    Yury 

     

     

  • Alun Davies's avatar
    Alun Davies
    Brass Contributor
    "I feel like this should be easy but i am having to much trouble trying to do this. "

    while as a human we can quickly get to pick this up there is a lot going on as it is you have 5 Cell rules with a lot of implied logic "the second heaviest left" for example.
    and as you can see in some of the "code" supplied this is what Excel has to do to get the result you need.

    I think you should consider other tools (excel is a spreadsheet not a database) have a try at ACCESS
    • SergeiBaklan's avatar
      SergeiBaklan
      MVP

      Hi David,

       

      In general everything is possible. Your sample is empty except errors in the cells. If you provide some sample with numbers and where you'd like to have which result that will be easier - bit hard to recover the logic of your model without the knowledge of what's that about.

       

      Thank you

      • David Attard's avatar
        David Attard
        Copper Contributor

        Hi Sergei,

        I have updated the spreadsheet to provide more details.

         

        TABS:

        Tracking - Data that will be recording from my workouts

        1RM - Calculator for 1RM based on the number in `Notes`

        Notes - This is where the fomulas are to get the highes rep, second hights rep and weights from my very first post. I used the fomulas from Yuri to get this all working. Happy to is it working with your formulas.

         

        I was curious if it was possible to do it horizontaly vs vertially to save having to type the exercise 4 - 5 for each workout. Seemed more logical with approach. Open to any other suggestion, i am trying to simplfy the repetiviness. I still have not work out a way from not have to type week 1, week 2 etc and the date the exercise was done, could do a macro bust seems like overkill to me.

  • Another variant is without array formulas

    First largest

    =AGGREGATE(14,6,(1/($C$2:$C$500=$K$1))*(E2:E500),1)

    Second largest

    =AGGREGATE(14,6,(1/($C$2:$C$500=$K$1))*(E2:E500),2)

    etc.

    • David Attard's avatar
      David Attard
      Copper Contributor

      Hi Sergei,

      Just letting you know your solution works however it was not quite what i was trying to achive. The result would sometimes be the wrong value and so i went with the array solution.

       

      I appreciate you taking the time to assist me though.

      • SergeiBaklan's avatar
        SergeiBaklan
        MVP

        Hi David,

         

        No problem, in my formula weight filter was missed. In general you may add as many filters as needed adding the multiplier. Formulas are

        =AGGREGATE(14,6,(1/($C$2:$C$500=$K$1))*(E2:E500)*($F2:$F$500=$L$9),1)
        =AGGREGATE(14,6,(1/($C$2:$C$500=$K$1))*(E2:E500)*($F2:$F$500=$L$10),1)
        =L4-L5
        =L9-L10
        =L7/L6
        =AGGREGATE(14,6,(1/($C$2:$C$500=$K$1))*(F2:F500),1)
        =AGGREGATE(14,6,(1/($C$2:$C$500=$K$1))*(F2:F500),2)

        and in attached file

         

         

  • Yury Tokarev's avatar
    Yury Tokarev
    Copper Contributor

    Hi David,

     

    please see attached for the sample solution. For the second highest rep I used the following formula (array entered):

    {=INDEX($E$2:$E$500,LARGE(IF($C$2:$C$500=K1,ROW($C$2:$C$500)-ROW(INDEX($C$2:$C$500,1,1))+1),2))}

    Similarily, for the second highest weight I used

    {=INDEX($F$2:$F$500,LARGE(IF($C$2:$C$500=K1,ROW($C$2:$C$500)-ROW(INDEX($C$2:$C$500,1,1))+1),2))}

     

    Hope this helps

    Regards

    Yury 

     

     

    • David Attard's avatar
      David Attard
      Copper Contributor

      Yury = Champion.

       

      Thanks mate, this was driving me crazy.

       

      Microsoft should make this into a function, I can see this being a common scenario and do a simple google shows im not the only one asking. 

       

      Thanks again.

Resources