Working with Resource Assignments
Variance tracking is an important part of project management because it allows you to compare actual results against planned baselines. Aspose.Tasks for .NET provides direct access to variance values through the Asn class, enabling developers to analyze project deviations programmatically.
Dealing Variances
The Asn
class exposes several properties for handling variance in an assignment’s baseline values and actuals:
- CostVariance – difference between baseline cost and actual assignment cost (double)
- StartVariance – difference between baseline start date and actual assignment start (integer, measured in tenths of a minute)
- FinishVariance – difference between baseline finish date and actual assignment finish (integer, measured in tenths of a minute)
- WorkVariance – difference between baseline work and actual work performed (double)
To view assignment variances in Microsoft Project manually:
- Go to the Task Usage screen.
- From the Insert menu, select Column.
- Add the variance columns you need.
Getting Assignment Variance in Aspose.Tasks
The following example demonstrates how to access the WorkVariance
value of a resource assignment programmatically. This allows you to determine how much actual work deviates from the baseline.
1Project project = new Project("New Project.mpp");
2
3// Print assignment variances
4foreach (ResourceAssignment ra in project.ResourceAssignments)
5{
6 Console.WriteLine(ra.Get(Asn.WorkVariance));
7 Console.WriteLine(ra.Get(Asn.CostVariance));
8 Console.WriteLine(ra.Get(Asn.StartVariance));
9 Console.WriteLine(ra.Get(Asn.FinishVariance));
10}
FAQ
Q: Do I need Microsoft Project installed to read variance values?
- No. Aspose.Tasks for .NET reads and calculates variance values independently of Microsoft Project.
Q: Can I access all types of variance (cost, start, finish, work) with Aspose.Tasks?
- Yes. The
Asn
class exposes all major variance fields for resource assignments.
Q: Are variance values preserved when saving the project back to Microsoft Project?
- Yes. Any variance data remains intact and can be viewed in Microsoft Project after saving.
Conclusion
Variance analysis in Aspose.Tasks for .NET makes it possible to programmatically track project deviations without relying on Microsoft Project. By using properties such as CostVariance
, StartVariance
, FinishVariance
, and WorkVariance
, developers can generate detailed progress reports, monitor project health, and ensure better cost and schedule control directly from C# code.