For the Actual Cost column, we start by creating a table variable, __Table, that contains all of the related records from the R04_Hours table and their respective costs. We do this by using the RELATEDTABLE function to return all the rows from the R04_Hours table that are related to the current row in the R04_Projects table. We add a column called __Cost_Per_Hour to this table using the ADDCOLUMNS function. This cost per hour comes from the R04_Resources table, so we use the RELATED function to return the related Cost_Per_Hour for each row of the R04_Hours table. Then, we add an additional column called __AC, which is simply the product of the Hours column from the R04_Hours table, and our new __Cost_Per_Hour column. Finally, we simply need to return the sum of the __AC column using SUMX. By using a column, we are assured that our Actual Cost provides the correct value at each level of the ad hoc hierarchy we created in our matrix visualization.
To display the cumulative actual costs over time, we use the AC measure. The calculation of this AC measure is nearly identical to our Actual Cost column. There are only two differences. The first difference is that we start by getting the maximum date within the current context of our line chart visualization, __Date. The second difference is that, instead of starting with a table that has been built using the RELATEDTABLE function, we use the FILTER function to filter rows within the R04_Hours table that have a Date column that is less than or equal to __Date.