简体   繁体   中英

How to calculate the percentage of the total, when the total includes the percentage -circular calculations

For this problem the final contract price needs to be calculated.

Let c be contract price = eg 100 i = interest (1% of c) g = another percentage (eg 1% of c)

The total contract price however, needs to be calculated using i and g of c + i + g. In other words the final value must include a total that calculates i and g (percentages) of the total of c+i+g. Is this even possible?

As we need to calculate i and g first, this seems impossible/circular.

I was trying to create something in python to simulate this but what we really want is a solution in excel.

Is anyone able to shed any light on such circular calculations which seem to depend on future values?

def totalcontractprice(c,i,g):
    x=c+i+g
    return x

def finalcontractprice(totalcontractprice):
    #here we want to return the finalcontract price
    #this should recalculate i and g as percentages of x (totalcontractprice)



c=100
i=1 #1 percent of c
g=1 #1 percent of c


print(totalcontractprice(c,i,g))

This can be solved in Excel using the iterative calculation option. Under Excel options > Formulas > Calculation Options, enable iterative calculations:

在此处输入图像描述

Before enabling iterative calculations you get the "Circular Reference" error:

在此处输入图像描述

After enabling iterative calculations, Excel will calculate:

在此处输入图像描述

Formula view to better see circularity:

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM