Hello everyone! I really, really need your help.
I need to calculate the total annual spend and the net present value for different projects. For that I have the following information in a table (sample info):
Annual average volume 4000
Program life time in years 8
Cost reductions 3% in 3 years 2% in 2 years
Piece price 1.50
The Rate% for the Present value calculation will be given in an input field in the app
I attached the table I need to create/simulate to be able to perform these calculations in excel. The explanation is as follows:
1. First I need to create a table with number of items from 0 to program life time in years . I store an index in the first column.
2. For column 2 I need to transform the text in the column "Cost reductions" to a column stating the year 0 no cost reductions, the next three years a reduction of 3% and the next 2 years a reduction of 2%
3. For column 3 I need to calculate the piece price for each year =Piece price of the previous year * (1-cost reduction of this year) (for the year 0 the piece price will be the one given in the item)
4. For the Total Spend column I need to multiply the calculated piece price of this year * annual average volume. The sum of this column will give me the Total Annual spend that I am looking for.
5. For the Present Value column I need to divide the total spend / (1-rate%)^ThisItem.year (the first column). The sum of this column will give me the Present Value
Until now I have created a collection as follows:
ForAll(Sequence(Value(Last(FirstN(Split(ThisItem.CostReduction, " "),3)).Result),1),Collect(Reduction1,{ReducPercentage:Last(FirstN(Split(ThisItem.CostReduction, " "),1)).Result,AnnualVol:LookUp(QBOM,QBOMIDinQBOM=ThisItem.QBOMIDinCBD1).TotalAnnualAvgCmpVolume,Index:CountRows(Reduction1)+1,PiecePrice:Left(Label64_1.Text,Find(" ",Label64_1.Text)),Spend:0}));
ForAll(Sequence(Value(Last(FirstN(Split(ThisItem.CostReduction, " "),7)).Result),1),Collect(Reduction2,{ReducPercentage:Last(FirstN(Split(ThisItem.CostReduction, " "),5)).Result,AnnualVol:LookUp(QBOM,QBOMIDinQBOM=ThisItem.QBOMIDinCBD1).TotalAnnualAvgCmpVolume,Index:CountRows(Reduction2)+CountRows(Reduction1)+1,PiecePrice:Left(Label64_1.Text,Find(" ",Label64_1.Text)),Spend:0}));
ForAll(Sequence(Value(Last(FirstN(Split(ThisItem.CostReduction, " "),11)).Result),1),Collect(Reduction3,{ReducPercentage:Last(FirstN(Split(ThisItem.CostReduction, " "),9)).Result,AnnualVol:LookUp(QBOM,QBOMIDinQBOM=ThisItem.QBOMIDinCBD1).TotalAnnualAvgCmpVolume,Index:CountRows(Reduction3)+CountRows(Reduction2)+CountRows(Reduction1)+1,PiecePrice:Left(Label64_1.Text,Find(" ",Label64_1.Text)),Spend:0}));
ForAll(Sequence(Value(Last(FirstN(Split(ThisItem.CostReduction, " "),15)).Result),1),Collect(Reduction4,{ReducPercentage:Last(FirstN(Split(ThisItem.CostReduction, " "),13)).Result,AnnualVol:LookUp(QBOM,QBOMIDinQBOM=ThisItem.QBOMIDinCBD1).TotalAnnualAvgCmpVolume,Index:CountRows(Reduction4)+CountRows(Reduction3)+CountRows(Reduction2)+CountRows(Reduction1)+1,PiecePrice:Left(Label64_1.Text,Find(" ",Label64_1.Text)),Spend:0}));
ClearCollect(Reduction,Reduction1,Reduction2,Reduction3,Reduction4); Clear(Reduction1);Clear(Reduction2);Clear(Reduction3);Clear(Reduction4);
as you can see the Piece Price the annual spend are not yet calculated.
My questions:
Is there a better way to get the cost reductions into the collection (maybe dynamically)?
How can I create the column piece price? (I have tried with For All, Sequence, Patch, ThisRecord.Index-1 but I can not find the right combination and I can not patch in the same source as the for all)
Is there a way to make a For All inside of a For All to make the calculation of the Total Annual Spend and the Present Value without creating a collection or how would you recommend me to do these calculations?
Every help is welcome!
Solved! Go to Solution.
I just saw that the piece price is 17.158 and is shown rounded up to 17.16, but the calculation is still done with the 17.158, for this reason there is a difference. If I use the 17.16 as piece price, the values I get are still different (see attachment).
Thanks for the clarification on the rounding. That made the difference.
So I am not seeing what you are seeing. If I plug 17.16 in for the piece price I get exactly what you have when you used 17.16 on the Spreadsheet.
Now, if I used the unrounded number 17.158 I get the exact same numbers you had in the prior spreadsheet:
Everything appears to be exactly what you are getting in the spreadsheet.
What am I missing?
So I see the difference. You are using a CR of 0% in 3 years 3% in 3 years
I am using a CR of 0% in 3 years 3% in 3 years 0% in 2 years
If I remove that last part, I get the numbers you are showing me. The curious thing is that even though in the example 4 we also have a 0% in 4 years at the end, it is not being affected. How is the 0% reduction in the 3 first years considered? Would this affect the number of loops it does at the end? Is it doing 2 additional loops or something? If you add the total number of years mentioned in the CR it results in 8 years, and the project only runs for 6 years. Could this somehow be used to stop the loop at the 6th year? I know that the 0% in 2 years at the end sounds crazy to have, but it is a macro that is getting these numbers into a table format to be able to use it in power apps.
Also, are you getting the error in the button saying that the first argument to Sequence must be between 0 and 50000?
Yes, I see the issue now if I add the 0% in 2 years. Which, by itself doesn't really make sense...if the term in years is 6, then 0% in 3 years and 3% in 3 years and 0% in 2 years is 8 years!!
Anyway, I will take a closer look at the formula and see where that becomes a problem.
As for the Sequence error...No, I do not see anything like that. What are you seeing??
You know what, you are right. I will find a way to improve my data before using the formula (now that I know where the problem is).
The sequence error is not there every time, so maybe it has to do also with the data I am using. I will have a deeper look into it.
Thank you very much for your help and your solution!
Very good! Yes, the formula will be sensitive to the CR format. It was built around the concept of how you originally had the string. So, changes to that will potentially result in problems. If you need to change the format, then the regular expression in that formula would need to be done differently.
Glad you have something working now!
User | Count |
---|---|
125 | |
87 | |
86 | |
75 | |
69 |
User | Count |
---|---|
216 | |
181 | |
140 | |
97 | |
83 |