How it works...

We start by creating a table variable, __Table, that contains all of the related records from the R02_Assignments table and their respective costs. We do this by using the RELATEDTABLE function to return all the rows from the R02_Assignments table that are related to the current row in the R02_Projects table. To this table, we add a column called __Cost_Per_Hour using the ADDCOLUMNS function. This cost per hour comes from the R02_Resources table, so we use the RELATED function to return the related Cost_Per_Hour for each row of the R02_Assignments table. Then, we add an additional column called __PV, which is simply the product of the Scheduled_Work column from the R02_Assignments table, and our new __Cost_Per_Hour column. Finally, we need to return the sum of the __PV column using SUMX. By using a column, we are assured that our Planned Value provides the correct value at each level of the ad hoc hierarchy we created in our matrix visualization.