+ Reply to Thread
Results 1 to 8 of 8

Rounding problems using lookup instead of rounding functions

  1. #1
    Registered User
    Join Date
    06-13-2014
    Posts
    10

    Rounding problems using lookup instead of rounding functions

    Hi.

    You guys introduced me to arrays/matrix use in excel the other day and I'm pretty happy about it. They open-up all kinds of ways to make my ideas more user-friendly. I am running into one problem though. I modified the formula I was given and nested another "if" and "lookup", but I have found a problem. For some numbers, this formula results in what is in effect a rounding error. In the following formula I have used 10.78 as the input cost and a margin of 23 (indicated by /.77) and the result is 14 on the nose. The problem is that the formula spits out 14.99 where the desired result is 13.99. If you go up to 10.79 the formula spits out 14.49 (this is the desired result). It should subtract 1 from the integer as well as placing 99 to the right of the decimal when in effect it is rounding down. I can't figure out how to do it right. I am guessing the answer is easier than I think, but my brain is fried. Maybe I should just use mround for the >=10 through <15 part, but I'd likely run into the same problem with the integer separated at the beginning.

    =INT((10.78/0.77))+IF(((10.78/0.77))<10, LOOKUP(MOD((10.78/0.77), 1)+0.001,{0,30,50,70,80,90}%,{29,49,69,79,89,99}%),IF(AND(((10.78/0.77))>=10,((10.78/0.77))<15),LOOKUP(MOD((10.78/0.77),1)+0.001,{0,0.01,50}%,{-1,49,99}%),LOOKUP(MOD(((10.78/0.77)), 1)+0.001, {0,25}%, {-1,99}%)))


    after closer inspection I have discovered that in excel (at least mine) "=MOD(14,1)+0.001" =0.001 and "=MOD(10.78/(1-0.23),1)+0.001" =1.001 which is confusing since 10.78/(1-0.23)=14

    I must be missing something disgustingly obvious

    thanks for any help
    jeff

  2. #2
    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: Rounding problems using lookup instead of rounding functions

    Computed in binary floating point, 10/.77 = 13.9999999999999, not 14.

    I suggest you calculate the price in a cell rounded to the nearest penny:

    =round(10.78/.77, 2)

    ... then apply the prior custom rounding formula.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    06-13-2014
    Posts
    10

    Re: Rounding problems using lookup instead of rounding functions

    I was able to insert the round function into the formula instead of messing around with adding more cells and it seems to work now. This is the finished (I hope)formula that I can apply to a vendor's price sheet after filtering and sorting to help keep our prices and margins consistent. (G being our cost, $H being the qty of items/case, $I is misc additions and shipping, and $G being the particular margin/item. thank you very much again!!!! Now I just have to convince my aging boss that doing all this stuff by hand on paper is the reason she is losing margins, and the time saved having the computer do this can better go towards customer service. That will be the hard part.


    =INT((((G2/data!$H$2)+data!$I$2)/(1-data!$G$2)))+IF((((G2/data!$H$2)+data!$I$2)/(1-data!$G$2))<10,LOOKUP(MOD(ROUND((((G2/data!$H$2)+data!$I$2)/(1-data!$G$2)),2),1)+0.001,{0,30,50,70,80,90}%,{29,49,69,79,89,99}%),IF(AND((((G2/data!$H$2)+data!$I$2)/(1-data!$G$2))>=10,(((G2/data!$H$2)+data!$I$2)/(1-data!$G$2))<15),LOOKUP(MOD(ROUND((((G2/data!$H$2)+data!$I$2)/(1-data!$G$2)),2),1)+0.001,{0,50}%,{49,99}%),LOOKUP(MOD(ROUND((((G2/data!$H$2)+data!$I$2)/(1-data!$G$2)),2),1)+0.001,{0,25}%,{-1,99}%)))
    Last edited by thnkfree; 06-17-2014 at 04:05 PM.

  4. #4
    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: Rounding problems using lookup instead of rounding functions

    You're welcome.

    I wouldn't do it that way, and I don't think a formula like that is a selling point to your 'aging boss,' but if you're happy with it, great.

  5. #5
    Registered User
    Join Date
    06-13-2014
    Posts
    10

    Re: Rounding problems using lookup instead of rounding functions

    really? maybe I'd have to show you the whole spreadsheet to see how I'm using it. I'm trying to use the same formula for lots and lots of items that vary by margin, additional costs, qty/case etc...I download a list of items and costs from a vendor, filter and sort everything according to serial numbers, then copy and paste the formulas into a table that pulls the margins and other things from another worksheet. It seems to me that the fewer cells I have to use and reference, the better. Anyway...unless you can look at the entire spread sheet, I don't think I could really ask for help with simplifying, but I think it's about as simple as I can make it. Can you think of a problem that could be caused by incorporating the round function like I did? I think it saves me a lot of work to do it this way. The spreadsheet is to large to attach (9mb) so I might be out of luck with that kind of advice
    Last edited by thnkfree; 06-17-2014 at 05:32 PM.

  6. #6
    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: Rounding problems using lookup instead of rounding functions

    You calculate the same value six times in that formula. Take pity on the guy that needs to try to figure out why someday.

    There's a price calculation and a rounding calculation, two simple and distinct aspects that are now rolled up in one needlessly complex formula. There are 16,000 columns on a worksheet; don't be afraid to use a few of them to expose the design.
    Last edited by shg; 06-17-2014 at 05:39 PM.

  7. #7
    Registered User
    Join Date
    06-13-2014
    Posts
    10

    Re: Rounding problems using lookup instead of rounding functions

    ahh I see what you are saying. I think that will require reworking an entire sheet, but I can see the advantage. Not gonna do it today though. After starting with little to no knowledge of excel, apart from what is possible, I have put this together in just under 2 weeks. I think I'm excelled out for a month or so. Even with the overly complicated formula it's a pretty cool, user-friendly spreadsheet if I do say so myself. I really do appreciate all the help

  8. #8
    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: Rounding problems using lookup instead of rounding functions

    You're welcome.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Problems with rounding down
    By Marcus1987 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 09-10-2012, 06:55 AM
  2. rounding up problems
    By nhush in forum Excel General
    Replies: 8
    Last Post: 07-12-2012, 11:52 PM
  3. Excel Rounding Problems
    By joejensen in forum Excel General
    Replies: 8
    Last Post: 01-20-2009, 05:45 AM
  4. [SOLVED] Sum and rounding functions
    By colleen in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-18-2006, 02:10 PM
  5. [SOLVED] Rounding up/down problems ?
    By Big Bad Nige in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-05-2006, 03:40 AM

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