Summarize Task Custom Fields in Microsoft Project
Question details
The user wants to summarize task custom fields, such as Revenue and Margin, at the project or portfolio level.
- Product
- Microsoft Project and Project Online
- Device & OS
- not provided
- Scenario
- A project manager needs totals or calculated metrics from task-level custom fields for one or more projects.
- Observed behavior
- Task custom field values need to be aggregated before they can be used in project-level or portfolio reporting.
Identify the underlying task field names and data types, such as Number1 for Revenue, rather than relying only on their display names. Decide whether to include summary tasks and whether Margin is an amount or a percentage.
Sum a task custom field with VBA in Microsoft Project
Use a VBA macro to calculate a total for the active project when a project-level custom field cannot directly aggregate task values.
The example totals Number1 for non-summary tasks and prints the result in the VBA Immediate window. It does not write the total to a project-level custom field.
Open the project in Microsoft Project and confirm that Revenue is stored in the task Number1 field. If it uses another numeric task field, replace Number1 in the macro with that field name.
Press Alt+F11 to open the VBA editor, choose Insert > Module, and paste: Sub SumTaskRevenue() Dim t As Task Dim total As Double For Each t In ActiveProject.Tasks If Not t Is Nothing Then If Not t.Summary Then total = total + t.Number1 End If Next t Debug.Print "Revenue total: "; total End Sub
In the VBA editor, press Ctrl+G to open the Immediate window, place the cursor inside SumTaskRevenue, and press F5. Read the Revenue total in the Immediate window.
Analyze published task fields across projects with Power BI
Use Project Online reporting data when you need a portfolio-level view across published projects.
Analyze exported project totals in WPS Spreadsheets
WPS Office is a free, lightweight alternative with a familiar interface and Microsoft Office format compatibility. Open exported project data in WPS Spreadsheets to summarize it, while keeping Microsoft Project or Power BI for native project data and reporting.

Frequently Asked Questions
Can a project custom field directly sum task custom fields?
A project-level custom field may not directly aggregate task-level custom fields. Use VBA to calculate a project total or use published Project Online data in Power BI for reporting.
How do I avoid counting task values twice in the VBA total?
Exclude summary tasks when their values already include subtasks. The example macro checks t.Summary before adding each task's Number1 value.
Should I sum the Margin field across tasks?
You can sum margin amounts when appropriate, but percentage margins should not simply be added. Calculate overall margin from total profit divided by total revenue instead.
Why is my custom field missing from Power BI?
Check that the project is published, the reporting data has refreshed, and the field is available in the Project Online reporting feed. In Power BI, reconnect through Home > Get data > OData feed and inspect the available tables and columns.




