SOLVED
Home

Error while calculating 64,1-0,1 - VLOOKUP

%3CLINGO-SUB%20id%3D%22lingo-sub-1005479%22%20slang%3D%22en-US%22%3EError%20while%20calculating%2064%2C1-0%2C1%20-%20VLOOKUP%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1005479%22%20slang%3D%22en-US%22%3E%3CP%3EHello!%3C%2FP%3E%3CP%3EI've%20noticed%20that%20VLOOKUP%20formula%20doesn't%20work%20properly%20while%20calculating%2064%2C1-0%2C1.%20I've%20made%20a%20small%20example%20to%20demonstrate%20this%20issue.%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThere%20are%20numbers%2063%3B%2064%3B%2063%2C1%3B%2064%2C1%20in%20column%20A.%20They%20are%20associated%20with%20numbers%201%2C2%2C3%2C4%20in%20column%20B.%20If%20I%20want%20to%20use%20function%20VLOOKUP%20in%20column%20D%20to%20associate%20numbers%20from%20column%20C%20with%20numbers%20in%20column%20B%20everything%20works%20fine.%26nbsp%3B%3C%2FP%3E%3CP%3EFunny%20thing%20happens%20if%20you%20want%20to%20associate%20numbers%20from%20column%20F%20with%20numbers%20in%20column%20B%20with%20VLOOKUP%20function%20as%20they%20are%20a%20result%20of%20a%20simple%20operation%3A%20number%20from%20column%20C%20-%200%2C1.%3C%2FP%3E%3CP%3EThe%20result%20of%20this%20simple%20operation%2064%2C10%20-%200%2C1%20%3D%2064%2C00%20is%20in%20the%20cell%20F5.%20I've%20even%20checked%20if%20the%20result%20is%20the%20same%20using%20formula%20in%20F7%20(%3DF5%3DA3).%26nbsp%3B%3C%2FP%3E%3CP%3EWhy%20do%20I%20get%20an%20error%20in%20G5%3F%20VLOOKUP%20function%20works%20perfectly%20fine%20in%20G4%2C%20but%20It%20does%20not%20give%20a%20correct%20result%20in%20G5.%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20you%20change%20number%2064%20to%20100%20in%20A2%20and%2064%2C10%20to%20100%2C1%20in%20C5%20everything%20works%20fine.%3C%2FP%3E%3CP%3EThere%20must%20be%20some%20king%20of%20a%20bug%20in%20calculating%2064%2C10%20-%200%2C10.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHow%20can%20I%20fix%20this%20issue%3F%20This%20error%20appears%20in%20Office%20365%20and%202016.%20File%20format%20xls%20or%20xlsx%20doesn't%20matter.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1005479%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1005834%22%20slang%3D%22en-US%22%3ERe%3A%20Error%20while%20calculating%2064%2C1-0%2C1%20-%20VLOOKUP%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1005834%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F456617%22%20target%3D%22_blank%22%3E%40radlek%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20is%20odd.%20I%20recreated%20your%20table%20in%20a%20new%20workbook%20and%20get%20the%20same%20result.%20The%20problem%20also%20occurs%20with%20the%20number%204.%20The%20lookup%20works%20fine%20if%20your%20formula%20in%20F%20is%20rounded%20to%201%20decimal%20like%20%22%3DROUND(.............%2C%201)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%2C%20of%20course%2C%20it%20should%20not%20be%20like%20that.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1006758%22%20slang%3D%22en-US%22%3ERe%3A%20Error%20while%20calculating%2064%2C1-0%2C1%20-%20VLOOKUP%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1006758%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F456617%22%20target%3D%22_blank%22%3E%40radlek%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThat's%20floating%20point%20error.%2064%20and%20%3D64.1-0.1%20are%20differ%20somewhere%20in%2016th%20or%2017th%20digit.%20Usually%20Excel%20takes%20into%20account%20first%2015%20digits%2C%20that's%20why%20you%20have%20TRUE%20compare%20two%20cells.%20But%20VLOOKUP%20checks%20all%2017%20digits.%20Here%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fsfmagazine.com%2Fpost-entry%2Faugust-2017-excel-rank-countif-and-floating-point-errors%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fsfmagazine.com%2Fpost-entry%2Faugust-2017-excel-rank-countif-and-floating-point-errors%2F%3C%2FA%3E%20is%20bit%20different%20case%2C%20but%20idea%20is%20explained%20in%20more%20details.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESuch%20errors%20appear%20from%20time%20to%20time%20when%20you%20do%20math%20with%200.1%20(sure%2C%20not%20only%20in%20such%20cases)%20due%20to%20nature%20of%20binary%20representation%20of%20it.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20workaround%20is%20to%20use%20something%20like%20%3DROUND(64.1-0.1%2C15)%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1006847%22%20slang%3D%22en-US%22%3ERe%3A%20Error%20while%20calculating%2064%2C1-0%2C1%20-%20VLOOKUP%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1006847%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EGood%20catch.%20Going%20back%20to%20the%20original%20file%20this%20works%2C%20too%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3DVLOOKUP(INT(F5)%2C%24A%242%3A%24B%245%2C2%2CFALSE)%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1006868%22%20slang%3D%22en-US%22%3ERe%3A%20Error%20while%20calculating%2064%2C1-0%2C1%20-%20VLOOKUP%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1006868%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F428790%22%20target%3D%22_blank%22%3E%40Patrick2788%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYah%2C%20if%20we%20assume%20that%20lookup%20value%20shall%20be%20only%20integer.%20In%20general%20it's%20ROUND(..%2C0)%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1007564%22%20slang%3D%22en-US%22%3ERe%3A%20Error%20while%20calculating%2064%2C1-0%2C1%20-%20VLOOKUP%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1007564%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20for%20your%20help.%20I%20read%20some%20articles%20regarding%26nbsp%3Bfloating%20point%20error%20but%20in%20my%20example%20even%20if%20you%20check%2016th%20or%2017th%20digit%20still%20you%20get%20exactly%2064.%20Maybe%20the%20difference%20stays%20hidden.%3C%2FP%3E%3CP%3E64%2C1-0%2C1%3D64%2C0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000%3CBR%20%2F%3E1%2C2-1%2C1%3D0%2C0999999999999999000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1008003%22%20slang%3D%22en-US%22%3ERe%3A%20Error%20while%20calculating%2064%2C1-0%2C1%20-%20VLOOKUP%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1008003%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F456617%22%20target%3D%22_blank%22%3E%40radlek%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EExcel%20by%20default%20works%20with%2015%20digits%20and%20round%20the%20rest.%20Only%20few%20algorithms%20in%20Excel%20calculation%20engine%20support%2017%20digits%20precision%2C%20but%20you%20will%20never%20see%2016th%20and%2017th%20digit%20in%20user%20interface%2C%20zero%20instead.%20Majority%20of%20functions%20also%20ignore%2016th%20and%2017th%20digit.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20may%20consider%20that%20as%20the%20bug%2C%20but%20that's%20the%20one%20which%20most%20probably%20never%20will%20be%20fixed.%20From%20this%20point%20of%20view%20same%20one%20as%20leap%20year%20for%201900.%20That's%20what%20we%20shall%20take%20as%20it%20is.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1008020%22%20slang%3D%22en-US%22%3ERe%3A%20Error%20while%20calculating%2064%2C1-0%2C1%20-%20VLOOKUP%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1008020%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3ELooking%20it%20up%20as%20an%20integer%20is%20the%20most%20likely%20of%20the%20two%20scenarios.%26nbsp%3B%20I%20think%20if%20you%20need%20to%20lookup%20a%20decimal%20that%20large%20then%20the%20question%20is%20-%20what%20are%20you%20trying%20to%20accomplish%3F%26nbsp%3B%20It's%20not%20very%20common.%3C%2FP%3E%3C%2FLINGO-BODY%3E
radlek
New Contributor

Hello!

I've noticed that VLOOKUP formula doesn't work properly while calculating 64,1-0,1. I've made a small example to demonstrate this issue.  

 

There are numbers 63; 64; 63,1; 64,1 in column A. They are associated with numbers 1,2,3,4 in column B. If I want to use function VLOOKUP in column D to associate numbers from column C with numbers in column B everything works fine. 

Funny thing happens if you want to associate numbers from column F with numbers in column B with VLOOKUP function as they are a result of a simple operation: number from column C - 0,1.

The result of this simple operation 64,10 - 0,1 = 64,00 is in the cell F5. I've even checked if the result is the same using formula in F7 (=F5=A3). 

Why do I get an error in G5? VLOOKUP function works perfectly fine in G4, but It does not give a correct result in G5. 

If you change number 64 to 100 in A2 and 64,10 to 100,1 in C5 everything works fine.

There must be some king of a bug in calculating 64,10 - 0,10.

 

How can I fix this issue? This error appears in Office 365 and 2016. File format xls or xlsx doesn't matter. 

7 Replies
Highlighted

@radlek 

 

This is odd. I recreated your table in a new workbook and get the same result. The problem also occurs with the number 4. The lookup works fine if your formula in F is rounded to 1 decimal like "=ROUND(............., 1)

 

But, of course, it should not be like that.

 

Highlighted

@radlek 

That's floating point error. 64 and =64.1-0.1 are differ somewhere in 16th or 17th digit. Usually Excel takes into account first 15 digits, that's why you have TRUE compare two cells. But VLOOKUP checks all 17 digits. Here https://sfmagazine.com/post-entry/august-2017-excel-rank-countif-and-floating-point-errors/ is bit different case, but idea is explained in more details.

 

Such errors appear from time to time when you do math with 0.1 (sure, not only in such cases) due to nature of binary representation of it.

 

The workaround is to use something like =ROUND(64.1-0.1,15)

Highlighted

@Sergei Baklan 

Good catch. Going back to the original file this works, too:

 

=VLOOKUP(INT(F5),$A$2:$B$5,2,FALSE)

Highlighted
Solution

@Patrick2788 

Yah, if we assume that lookup value shall be only integer. In general it's ROUND(..,0)

Highlighted

@Sergei Baklan 

Thank you for your help. I read some articles regarding floating point error but in my example even if you check 16th or 17th digit still you get exactly 64. Maybe the difference stays hidden.

64,1-0,1=64,0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
1,2-1,1=0,0999999999999999000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

Highlighted

@radlek 

Excel by default works with 15 digits and round the rest. Only few algorithms in Excel calculation engine support 17 digits precision, but you will never see 16th and 17th digit in user interface, zero instead. Majority of functions also ignore 16th and 17th digit.

 

We may consider that as the bug, but that's the one which most probably never will be fixed. From this point of view same one as leap year for 1900. That's what we shall take as it is.

Highlighted

@Sergei Baklan 

Looking it up as an integer is the most likely of the two scenarios.  I think if you need to lookup a decimal that large then the question is - what are you trying to accomplish?  It's not very common.

Related Conversations
MSTeams Groups in outlook with macros disabled
ReadyorNot in Microsoft Teams on
0 Replies
Unknown Login Error
Alex_P3462 in Microsoft Teams on
0 Replies
Spelling Pop-Up Stuck on SharePoint List
aricornish in SharePoint on
0 Replies
Problem with OneDrive
esholder in OneDrive for Business on
5 Replies