Forum Discussion
christophe_schram
Apr 27, 2024Copper Contributor
Is it possible to customize the Task cost calculation?
I have a question on how to customize the calculation of Task costs. A bit of context: in my research organization, most of our research projects are funded by institutions (European Commission, ...
- Apr 27, 2024
Christophe,
First, I suggest you read this Wiki article on data types in Project:
https://web.archive.org/web/20200720083203/https://social.technet.microsoft.com/wiki/contents/articles/31991.ms-project-data-types-task-resource-assignment.aspx
Then you might also want to read the article referenced in the above concerning extra fields:
https://web.archive.org/web/20200722225529/https://social.technet.microsoft.com/wiki/contents/articles/32051.ms-project-extra-fields-in-views.aspx
Those articles will explain why your formulas don't seem to do what you want. However, based on your description, I don't see a need for custom cost fields at all. Instead of creating separate custom fields for funding types and resource types, why not combine the two. For example, you could have an EC work resource, an EC material resource, an EC cost resource, a Regional work resource, Regional material resource, a Regional cost resource, and so forth for each funding entity. Set up each resource type with the appropriate rate based on how they fund. You can even set up a time based cost escalation and/or up to 5 separate cost rates for each resource via resource cost rate tables A through E. This is accessible through the Cost tab on the Resource Information window. Varying cost rate tables for each resource are applied via the Cost Rate Table field at assignment level on either the Task Usage view or the Resource Usage view.
Hope this helps.
John
John-project
Apr 27, 2024Silver Contributor
Christophe,
First, I suggest you read this Wiki article on data types in Project:
https://web.archive.org/web/20200720083203/https://social.technet.microsoft.com/wiki/contents/articles/31991.ms-project-data-types-task-resource-assignment.aspx
Then you might also want to read the article referenced in the above concerning extra fields:
https://web.archive.org/web/20200722225529/https://social.technet.microsoft.com/wiki/contents/articles/32051.ms-project-extra-fields-in-views.aspx
Those articles will explain why your formulas don't seem to do what you want. However, based on your description, I don't see a need for custom cost fields at all. Instead of creating separate custom fields for funding types and resource types, why not combine the two. For example, you could have an EC work resource, an EC material resource, an EC cost resource, a Regional work resource, Regional material resource, a Regional cost resource, and so forth for each funding entity. Set up each resource type with the appropriate rate based on how they fund. You can even set up a time based cost escalation and/or up to 5 separate cost rates for each resource via resource cost rate tables A through E. This is accessible through the Cost tab on the Resource Information window. Varying cost rate tables for each resource are applied via the Cost Rate Table field at assignment level on either the Task Usage view or the Resource Usage view.
Hope this helps.
John
- christophe_schramApr 29, 2024Copper Contributor
Thanks John-project, this helped a lot. I read the articles you suggested, and understand better the differences between Task, Resource and Assignment data now.
I agree with your suggestion, the Cost Rate Tables seem indeed the natural solution.
I'm now trying to wite a macro creating the Cost Rate Table B for the EC hourly rates using the raw hourly costs of Table A:
Sub AssignHorizonEuropeCostRatesToCostRateTableB() Dim projApp As Object Dim resource As Object Dim costTableA As Object Dim costTableB As Object Dim rateIndex As Integer ' Create an instance of MS Project Set projApp = CreateObject("MSProject.Application") If projApp Is Nothing Then MsgBox "MS Project is not installed." Exit Sub End If projApp.Visible = True ' Set the active project Set ActiveProject = projApp.ActiveProject ' Loop through all active resources For Each resource In ActiveProject.Resources ' Specify the resource cost rate tables Set costTableA = resource.CostRateTables("A") Set costTableB = resource.CostRateTables("B") ' Table B rates = (Table A rates) * 1.25 For rateIndex = 1 To costTableA.PayRates.Count costTableB.PayRates(rateIndex).StandardRate = costTableA.PayRates(rateIndex).StandardRate * 1.25 costTableB.PayRates(rateIndex).OvertimeRate = costTableA.PayRates(rateIndex).OvertimeRate * 1.25 Next rateIndex Next resource End Sub
It's nearly working at the exception of a type mismatch error in the last couple of instructions (I'm completely new to VBA, this was largely inspired by Copilot), which I should be able to fix.
But the next step then will still be the creation of a custom field Cost1, which will use the Table B rates instead of the Table A ones. Would that be possible? I haven't found how.
- John-projectApr 29, 2024Silver Contributor
I'm glad the reference links gave you some insight. What I don't understand though is why you still think you need a custom cost field. Maybe a marked up screen shot would help.
I also don't understand why you need a macro to create the cost rate tables. Unless there are several tables with multiple time based changes, setting them up should only take a few minutes manually. If you still want to pursue a VBA approach and the code you posted is coming from Copilot, I find another airline.
John
- christophe_schramApr 29, 2024Copper Contributor
Hi John-project , Ignacio_Martin ,
Following your suggestions, here is what it should look like in the Task Usage view: