+ Reply to Thread
Results 1 to 8 of 8

Add weighted variable to existing value

  1. #1
    Registered User
    Join Date
    06-09-2010
    Location
    Mass
    MS-Off Ver
    Excel 2007
    Posts
    12

    Add weighted variable to existing value

    Hope someone can help with what I am, trying to do

    I have a spreadsheet with numerous values in cells. I need a formula to modify those cells with a number in a weighted range.

    e.g.

    Say I have the value 75 in a cell.. lets say B2 if it matters
    I want to add 0,1,2,3,OR 4 to it
    29% chance it will be 0, 30% it will be 1, 20% it will be 3, and 21% it will be 4

    It doesn't need to output this new value to a new cell, simply modify the existing cell.


    Truly appreciate any help you more experienced users can provide.
    Last edited by macross; 12-27-2010 at 02:56 AM. Reason: Solved

  2. #2
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Re: Add weighted variable to existing value

    =LOOKUP(RAND(),{0,0.29,0.59,0.79,0.99},{0,1,3,4,2})+$B$2
    note that this part of the formula below is the sum of the chances :-
    0.29 chance (29%) of 0, 0.59 = 30%+29% chance of 1, 0.79 = 30%+29%+20% chance of 3

    {0,0.29,0.59,0.79,0.99}


    since you left out the number 2 I wasnt quite sure how that came into it, so I added it to the end with a 1% chance!
    Regards
    Darren

    Update 12-Nov-2010 Still job hunting!

    If you are happy with the results, please add to our reputation by clicking the blue scales icon in the blue bar of the post.

    Learn something new each day, Embrace change do not fear it, evolve and do not become extinct!


  3. #3
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Re: Add weighted variable to existing value

    Note you cant modify the existing value with a formula, unless you use VBA or the value is generated with a formula in which case you can add the value to the cell.

  4. #4
    Registered User
    Join Date
    06-09-2010
    Location
    Mass
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Add weighted variable to existing value

    I had actually figured out another way to do this before you replied, but your solution is much cleaner and will allow me to do a little more than what I came up with. I can live without the direct cell output so that is fine too.

    I don't suppose there is an easy way to add an IF type statement to this so that the formula won't apply itself if it finds a certain value in another cell

    e.g.

    A1=75 B1=1
    A2=70 B2=2
    A3=85 B3=10
    etc etc

    Have your formula apply to the A cell but have the formula not modify the A value if the adjacent B value = 2 (Still needs to output the unmodified A values though in those cases.

  5. #5
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Re: Add weighted variable to existing value

    =if(A2=2,$b$2,LOOKUP(RAND(),{0,0.29,0.59,0.79,0.99},{0,1,3,4,2})+$B$2)

  6. #6
    Registered User
    Join Date
    06-09-2010
    Location
    Mass
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Add weighted variable to existing value

    Wonderful, thank you!

  7. #7
    Registered User
    Join Date
    06-09-2010
    Location
    Mass
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Add weighted variable to existing value

    So I took your formula and expanded on it, this look ok to you still?

    Please Login or Register  to view this content.
    It is supposed to allow for 3 weighted variables based on the value of an additional cell but also still returns the original value if one cell = 1009 or that other cell is 3+

  8. #8
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Re: Add weighted variable to existing value

    you could do this to shorten it!

    =IF($J3=1009,A3,A3+CHOOSE($G3+1,LOOKUP(RAND(),{0,0.25,0.6,0.85,0.95},{0,1,2,3,4}),LOOKUP(RAND(),{0,0.45,0.85,0.95},{0,1,2,3}),LOOKUP(RAND(),{0,0.75,0.95},{0,1,2}),0,0))

+ 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