Part 2 - Metrics
Last updated
Last updated
In the first section of solving this part, we going to split up the output from Part 1 (use an Output tool at the end of Part one above) into two streams - one for the Gross Profit Margin (GPM, top) and one for the Operating Profit Margin (OPM, bottom).
We start with a Filter to remove all the irrelevant rows - we only need Sales and Cost of Sales to caluclate GPM and Sales and >EBIT< to calculate OPM. We remove some unnecessary columns with Change Columns tools.
The complexity comes from the Transpose. Later on in the model, we need to make a formula to calculate of margins - we need the data (e.g. Sales and Cost of Sales) to be on the same row to do so. The Transpose is the first step to achieving that. We begin transforming our value columns (Y2018, Y2019, Y2020) to rows keeping the Account constant. The Transpose is made to do that. See the config below.
The second section of this part is about calculating our metrics. We do that with a Compare tool and a Calculate. The Compare tool is what really helps us achieve what we want. The entire second section looks like this:
The Compare tool helps us move data between rows, i.e. vertically in our dataset. Take a look below at the configuration of the first compare (Tool ID 144):
Let's begin with the output column prev_Value. This one is fetching the previous cell of the column Value. So the number from Value column on row 1 will show up in the number of prev_Value on row 2. We also use the Option Setting "Group By" to reset our calculation everytime we see a new year in the column Columns. In doing all of this, we move the Sales and the Cost of Sales to the same row - and now we can calculate with it! The calculations - Tool ID 145 and 159 - are faily simply. You can see the formula in the first screenshot here. Afterwards we remove the rows without any calculation with the Filter tools.
The final step we simply use a Combine tool to merge the two streams of data back together. We Combine using an Inner Join on the Year column. It looks like this:
In totality, our full model looks like this: