I'm programming a projectscheduler and want to calculate the percentage of finishing by looping through all the subprojects and calculate their weight and how many percent is done by now and then summate them to a final result for the mainproject. The structur would look similar to this:
- Project 1
- Project 1.1 (5 days,30% done)
- Project 1.2
- Project 1.2.1 (59 days, 52% done)
- Proejct 1.2.2 (10 days, 100% done)
So now I would start on the lowest layer (1.2.x) to calculate the weight of 1.2. Then I would do the same for the layer 1.x to get the final result. But I think calculating with days is not very accurate. Somebody have a pointer or a hint how I could calculate such an operation the best way to get as much accurancy as possible? I thought about calculating with 24 hours and not with days.
Cheers
I assume the weights $w_i$ of the subprojects $i=1,\ldots,n$ are the days needed. Let $p_i$ be the progress of subproject $i$. Then the weighted average of the entire project is $$P=\frac{\sum_{i=1}^n p_i w_i}{\sum_{i=1}^n w_i},$$ where $\sum_{i=1}^n w_i$ is just the overall number of days required to finish the project (sum of all subprojects). You might want to multiply $P$ with 100 to get the progress in percent. Since both the numerator and denominator are in days, it does not matter whether you recalculate the weights in hours - it would cancel out anyway.
For your example, it would be $$P=\frac{5*0.3+59*0.52+10*1}{5+59+10}.$$
You can also calculate the number of days left as $L=P*\sum_{i=1}^n w_i$. Here it does matter whether $w_i$ is in days or hours.