Now that we have successfully written a Rules Allocation Dimension, we have the option to add another element to allow for a more nuanced allocation of cost.
The cost formation language in the example up to now is sufficient for the majority of use cases. Previously, we allocated spend for a shared database relative to the cost of 3 products using the database. There may be instances where we want to allocate spend in a more nuanced way.
For example, let's say the shared database in the previous example is also shared across Development and Production environments. Each of our three products have some costs associated with Development, and some costs associated with Production. Rather than allocating the shared database costs by the overall proportions of SingleTenantProduct cost, we want to proportionally allocate spend to SingleTenantProduct by Environment as well.
Previously we were allocating the cost of the RDS Database to each product relative to that product's cost.
Our goal now is to allocate the cost of the RDS Database to each product relative to that product's cost by environment.
As we can see, $50 of spend shifted between Product B and Product C due to the higher relative ratio of Product C to Product B spend in Development.
For the purposes of this exercise, we'll assume we've already created a dimension called
Environmentthat describes the spend of Development and Production Environments.
We can add
ForEachElementOf to our existing dimension to achieve the desired effect above.
Now our overall dimension looks like this:
Name: Shared RDS
DefaultValue: Not Shared
- Type: Group
Name: Shared Data Lake
- Source: Service
Name: Split Data Lake
- Equals: Shared Data Lake
- Product A
- Product B
- Product C
Notice that under
ForEachElementOf we have used the
GroupBy shorthand to clearly express the logic. It is also possible to use the
Groups shorthand or the standard
Rules long form syntax. A full overview of how to write Rules Allocation Dimensions can be found here: Short Form Rules.
Updated about 3 hours ago