+ Reply to Thread
Results 1 to 12 of 12

multiple values dependent on their own sum (circular reference)

  1. #1
    Registered User
    Join Date
    12-16-2015
    Location
    Brno, Czech Republic
    MS-Off Ver
    2007
    Posts
    3

    multiple values dependent on their own sum (circular reference)

    I have a set of values which always have to add up to a certain value, but if one of these values is change, all the other values should make up for it.
    Is there a way of doing this without using VBA?

    In a bit more detail:

    I have a number of products with a set fixed cost (production, shipment and so on). On the other hand I have costs which are general and have to be distributed onto the products.
    So far so good and not a problem.
    However, after adding the indirect cost, some products end up being well above a certain pre set limit for this particular product, so I want to manually reduce it to be within this limit. When I do this, the part of indirect cost, which now is not covered by this particular product, has to be taken up by the remaining products.

    Since the whole thing should be automated I cannot do it for every individual case separately.
    Last edited by Philipp O.; 12-16-2015 at 10:42 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    08-06-2013
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2013
    Posts
    671

    Re: multiple values dependent on their own sum (circular reference)

    Try this:
    A1:A3 =
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    A4 =
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    File->Options->Formulas->Enable Iterative Calculation.
    1. Include a sample workbook with an example of the result you want
    2. Use [CODE] and [FORMULA] wrappers for your VBA code or excel formulas
    3. If your question has been answered, mark the thread as SOLVED and click on the "Add Rep" star to thank whoever helped you.

  3. #3
    Registered User
    Join Date
    12-16-2015
    Location
    Brno, Czech Republic
    MS-Off Ver
    2007
    Posts
    3

    Re: multiple values dependent on their own sum (circular reference)

    Hey k64,

    Thanks for your reply.
    I'm afraid this doesn't do the trick. I tried similar things before.

    Philipp

  4. #4
    Valued Forum Contributor
    Join Date
    08-06-2013
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2013
    Posts
    671

    Re: multiple values dependent on their own sum (circular reference)

    Well, unless you have additional detail or a sample workbook, VBA will be your best bet. You can make user-defined functions that act like normal excel functions but might not be restricted by circular references.

  5. #5
    Registered User
    Join Date
    12-16-2015
    Location
    Brno, Czech Republic
    MS-Off Ver
    2007
    Posts
    3

    Re: multiple values dependent on their own sum (circular reference)

    I updated my initial post. Have a look, maybe it's clearer now.
    The problem with VBA a is that firstly I don't really know how to use it and secondly that once I'm done with this file I want to share it with quite a few people. If they wouldn't activate the macros, the whole thing wouldn't work. Or am I mistaken there?

  6. #6
    Valued Forum Contributor
    Join Date
    08-06-2013
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2013
    Posts
    671

    Re: multiple values dependent on their own sum (circular reference)

    You can set macros to run at the click of a button, when someone opens the sheet, when a value is changed, etc. Or you can set them up as functions so they act like excel functions. I'm fairly sure the iterative calculation approach would work too, but if were me, I would make a macro, either as a user-defined function, or triggered whenever someone changes a value on the sheet.

  7. #7
    Valued Forum Contributor
    Join Date
    08-06-2013
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2013
    Posts
    671

    Re: multiple values dependent on their own sum (circular reference)

    For example, if you were making a macro to activate when the worksheet changed, you would add this code to the worksheet module. Change rng to match the cells you want to activate the macro.

    Please Login or Register  to view this content.

  8. #8
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: multiple values dependent on their own sum (circular reference)

    As a mathematician, I tend to first make these math problems before making them programming problems.

    As a math problem, this looks like it should be simple addition, so it should not need iterative algorithms. I see:

    totalcost(i)=productspecificcosts(i)+generalcosts*fraction(i)<=maxtotalcost(i)

    By solving the right inequality for fraction(i), we can easily compute the maximum fraction of general costs that can be attributed to product(i). Once I have a list of these maximum fraction(i)'s, I can then use that to inform how I should distribute the general costs across the products. You have not described anything about how you want to distribute these costs across the products (as evenly as possible? in proportion to total cost? some other criteria?). With a solid calculation of the maximum that each product can receive, and some idea of how you want to distribute these general costs, it should be possible to simply create a function that will decide the distribution up front, without the need for iterative calculations or VBA or other complications (most of the real work is in the algebra, though, so this may not be suitable for the mathophobic).

    In the example, I assume that I want a strictly even distribution of the general costs. I also assume that any costs that need to be "pushed" get pushed into product i (without any checks to see if product i goes over). By pressing F9, you can update the random numbers and see what happens in different scenarios.
    Attached Files Attached Files
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  9. #9
    Valued Forum Contributor
    Join Date
    08-06-2013
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2013
    Posts
    671

    Re: multiple values dependent on their own sum (circular reference)

    MrShorty,

    I like your approach. I have a question about it though. Maybe I'm misunderstanding the original question, but I thought the numbers should add up to the same total. When I look at your sheet, the total changes. What am I missing?

  10. #10
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: multiple values dependent on their own sum (circular reference)

    Recognize that the constantly changing nature of my spreadsheet is due to the RAND() functions, which change with each calculate event. Each set of random numbers represents a completely new scenario. If needed, you can copy -> paste special -> as values to fix these random numbers and look at a single random scenario.

    My understanding was that the general or indirect cost was a constant. In the algebraic formulation I envisioned, this is represented as sum(fraction(i))=1, which I force to be true in E13 and F13. If you add a column =$D$2*F5, you will see that the sum of this column will always equal $D$2 (with allowance for rounding error).

  11. #11
    Valued Forum Contributor
    Join Date
    08-06-2013
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2013
    Posts
    671

    Re: multiple values dependent on their own sum (circular reference)

    That makes sense. It seems like the totalcost for product i goes over its max cost, which isn't what I would expect.

  12. #12
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: multiple values dependent on their own sum (circular reference)

    As I noted, the way I set this up, all of the "extra" cost gets pushed into product i, and I did not go to the trouble to rectify that, because I was not sure exactly how the OP would want to distribute this. If this were the preferred method, I would probably sort the data by "max fraction" so that product a is the least likely to be able to accept its full allotment, and product i would almost certainly be able to absorb the excess. Then you would not see that.

+ 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. Replies: 2
    Last Post: 08-07-2014, 04:36 AM
  2. Replies: 2
    Last Post: 02-23-2014, 06:06 PM
  3. [SOLVED] Dependent Dropdown List Using Index and Small Won't Return Multiple Values
    By ebevis in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-23-2013, 02:28 AM
  4. Replies: 3
    Last Post: 07-12-2013, 11:10 PM
  5. =formula to copy values only to avoid circular reference
    By dainova in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-04-2013, 07:29 PM
  6. Circular Reference when formulas reference end of row formula!
    By Spellbound in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-29-2009, 08:26 AM
  7. Replies: 1
    Last Post: 08-21-2007, 07:22 PM

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