History patterns
In the previous chapters, we have seen how to define proper HKEY
and HDIFF
fields, use the save_history
macro to store the versions of the entities that we see over time, and use the current_from_history
macro to read the current version for each instance of the entity out of the history table.
We have also seen how we can use the HDIFF
field as a version identifier to be used in facts when we do not just care about the current version but we want to use dimensions with all the historical versions, also known as SCDT2 dimensions.
When talking about how to calculate the open positions in our portfolio from some periodic extract of the active portfolio, we introduced the problem of deletions from source data, and we created a solution to detect deletions to recognize closed positions.
One important caveat of the loading pattern of the save_history
macro is that it can handle one version per key, per load. This is simple to achieve by using a QUALIFY
clause in...