+ Reply to Thread
Results 1 to 11 of 11

Exact match with decimals doesn't work

  1. #1
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Exact match with decimals doesn't work

    hey guys. i was helping someone solve a problem awhile back & i guess it still bugs me why the MATCH formula couldn't work. despite having a work-around, i'm curious to know what went wrong.

    let's simplify things & say i only want to lookup the decimal of this number in A1:
    1.2
    0.1 0.2 0.3

    and i want to match it to the table below & return its position. so i do a formula:
    =MATCH(MOD(A1,1),A3:C3,0)
    or
    =MATCH(A1-INT(A1),A3:C3,0)
    both gives me #N/A when it's supposed to be 2. but keying the "0.2" would work:
    =MATCH(0.2,A3:C3,0)

    any ideas why?

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  2. #2
    Valued Forum Contributor Miraun's Avatar
    Join Date
    04-03-2009
    Location
    New England
    MS-Off Ver
    2003, 2007, 2010, 2013
    Posts
    554

    Re: Exact match with decimals doesn't work

    This may be a case of Excel Math Magic...

    Excel is actually based on a form of binary math, IEEE 754, which is an international computational standard... Essentially it's functioning in a base 8 rather than a base 10 world. It makes for some really strange results when doing seemingly simple math, but it's also the reason that 10/3 doesn't end up in your CPU going through an endless loop. Essentially, it does calculations in base 8, and then messing with the math on the seemingly insignificant level (like, 10 points from the decimals that you'd normally be interested in!), in order to make it round numbers (most of the time).

    Sadly, there's no real workaround, unless you go into Excel Options and toggle "Set Precision as Displayed" under Advanced > Formulas area. But there are other implications, as I'm sure you can clearly tell.

    Alternatively, you can use ROUND functions around the seemingly simply stupid math to tell excel to cut it out with the additional billionth decimal point.

    Give that a shot, and see if you continue to have the problems.
    Going for Guru! Click the Star to the bottom left of this post if I helped!

  3. #3
    Valued Forum Contributor Miraun's Avatar
    Join Date
    04-03-2009
    Location
    New England
    MS-Off Ver
    2003, 2007, 2010, 2013
    Posts
    554

    Re: Exact match with decimals doesn't work

    Ohh... Looking at the way that you've set out the data, rather than using a match function, you could use a LOOKUP function to round it to the different columns you have identified... which you could then use in a V or H lookup, similarly to the last forum post that we both commented on.

  4. #4
    Forum Contributor
    Join Date
    08-01-2012
    Location
    Chicago
    MS-Off Ver
    Excel 2010
    Posts
    112

    Re: Exact match with decimals doesn't work

    =MATCH(VALUE("0"&MID(A1,FIND(".", A1), (LEN(A1)-FIND(".", A1)+1))),A3:C3,0)

    this seems to work

  5. #5
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Exact match with decimals doesn't work

    @Miraun: ahhhh i was afraid to hear of such an answer. it seems that someone has asked before since you managed to write an essay within 3 minutes haha. i guess i'll have to accept a work-around then. yes LOOKUP or VLOOKUP would work but i was curious why MATCH couldn't since both my formulas are exactly equals to 0.2

    @ajm123456789: yeah i know there are work-arounds, as mentioned in my OP, but i'm just curious why this doesn't work

    i'll mark it as "Solved" anyway. thanks guys

  6. #6
    Registered User
    Join Date
    05-08-2016
    Location
    usa
    MS-Off Ver
    google
    Posts
    3

    Re: Exact match with decimals doesn't work

    Not sure if this helps. Had to create a stop loss protection for our company to prevent paying out excessive profit sharing. When company-wide GP is less than 2.5%, we bank all profit share. Between 2.5% and 5%, we payout 50% and bank/hold the other 50% to pay out later. People receive their entire profit share (and any banked profit share) once company GP is above 5%. To accomplish this, you need to have at least two rows per value or range as shown below.

    Set the table up in ascending order with the range of company GP. Left column contains formula =(Company GP Cell Reference)*10000. If you the GP were longer decimals (i.e. 2.49999%), you'd have to include a Round() statement to get rid of excess decimals.
    Between -9999% to 2.49%, there should be a payout reduction of 100%.
    Between 2.5% and 4.99%, we pay 50% of the persons profit share.
    Greater than 5% GP, employees receive 100% profit share.

    This is what the table needs to look like for index match to work:
    Rounded format Company GP Payout Reduction (reverse, bank)
    Column O Column P Column Q
    -999900 -9999.00% 100.00%
    249 2.49% 100.00%
    250 2.50% 50.00%
    499 4.99% 50.00%
    500 5.00% 0.00%
    99999900 999999.00% 0.00%

    Setup another table as: (formulas could be combined to simplify)
    Company GP 4.99%
    Company GP Formatted 499
    PS Reduction 50.00%
    PS Bank 50.00%

    Company GP (J11) 4.99%
    Company GP Formatted (J12) =round(J11*10000,0)
    PS Reduction (J13) =INDEX(Q:Q,match(J12,O:O,1))
    PS Bank =1-J13

  7. #7
    Registered User
    Join Date
    05-08-2016
    Location
    usa
    MS-Off Ver
    google
    Posts
    3

    Re: Exact match with decimals doesn't work

    sorry for formatting. Not sure to have tabs in this forum.

  8. #8
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,169

    Re: Exact match with decimals doesn't work

    Can you start your own thread rather than "hijacking" an existing one already designated as SOLVED..

    And it would help if you posted a sample file on the forum. To upload a file;

    Click "Go Advanced" then scroll down to "Manage Attachments"

  9. #9
    Registered User
    Join Date
    05-08-2016
    Location
    usa
    MS-Off Ver
    google
    Posts
    3

    Re: Exact match with decimals doesn't work

    Sorry, was looking for an answer to this same issue. The provided solution wasn't what I was looking for, so I was sharing the solution that did solve the same problem, even though the thread was marked as "solved". You'll note, benishiryo noted, "i'll mark it as "Solved" anyway. thanks guys" meaning he probably wanted something else as well.

    In any case, I wasn't Hijacking a thread that was solved, but providing a solution to an unsolved problem. I will not respond to another thread like this as requested. Thank you.

    Thanks for tip on uploading files. That is huge help. My formatting sucked.

  10. #10
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,169

    Re: Exact match with decimals doesn't work

    Thanks for the feedback: now appreciate why you responded.

    As you noted, uploading a file is the best (and probably) quickest way to get a response to any query, not least because it provides respondents with data to test any solution.

  11. #11
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Exact match with decimals doesn't work

    dawsonh2002 welcome to the forum

    If you are answering a post, even if it is marked solved, you are more than welcome to. Posting your own question on someone elses thread (which you were not doing) is a no-no here
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

+ 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