Forum Discussion

vanilla8910's avatar
vanilla8910
Copper Contributor
Aug 03, 2023
Solved

Vlookup approximate match giving wrong result

Hello, I use vlookup to categorise the average price into price range buckets. However, I'm getting inconsistent results:

WeightTotal priceAverage price
40.268340Weight/Total = 1700 (c8)

 

Lookup table:

ThresholdPrice range
165044: $1650 - <$1700
170045: $1700 - <$1750

 

Formula used:

=VLOOKUP(C8,'Lookup table',2,TRUE)

-> return 44: $1650 - <$1700

 

However, if I type '1700' into a cell and vlookup against that cell, it returns '45: $1700 - <$1750' which is the correct answer.

 

I have removed all decimals on the 'Weight' and 'Total price' by using the 'decrease decimal' icon in the ribbon, but it still returns '44: $1650 - <$1700'. 

 

Is this a bug and is there a way around this to get excel to return '45: $1700 - <$1750'?

  • vanilla8910 Decreasing the number of decimals displayed isn't going to help as the numer that is used by Excel in the calculation stays the same. To overcome your problem you need to round the calculation to 0 decimals like this:

    in C8: =ROUND(A8/B8,0)

     

    or change the VLOOKUP to this:

    =VLOOKUP(ROUND(C8,0),'Lookup table',2,TRUE)

     

     

2 Replies

  • Riny_van_Eekelen's avatar
    Riny_van_Eekelen
    Platinum Contributor

    vanilla8910 Decreasing the number of decimals displayed isn't going to help as the numer that is used by Excel in the calculation stays the same. To overcome your problem you need to round the calculation to 0 decimals like this:

    in C8: =ROUND(A8/B8,0)

     

    or change the VLOOKUP to this:

    =VLOOKUP(ROUND(C8,0),'Lookup table',2,TRUE)

     

     

    • vanilla8910's avatar
      vanilla8910
      Copper Contributor

      Riny_van_Eekelen thank you so much! that makes perfect sense now I realise the formula bar is still showing 40.2 but the cell is showing 40. 

Resources