I'm working on a quarterly report. The report should look something like this:
col | Calculation | Source table |
---|---|---|
Start_Balance | Sum at start of time period | Account_balance |
Sell Transactions | Sum of all sell values between the two time periods | Transactions |
Buy Transactions | Sum of all buy values between the two time periods | Transactions |
End Balance | Sum at the end of time period | Account_balance |
so e.g.
Calculation | sum |
---|---|
Start_Balance | 1000 |
Sell Transactions | 500 |
Buy Transactions | 750 |
End Balance | 1250 |
The problem here is that I'm working with a relational star schema, one of the facts is semi-additive and the other is additive, so they behave differently on the time dimension.
In my case I'm using Cognos analytics, but I think this problem goes for any BI tool. What would be best practice to deal with this issue? I'm certain I can come up with some sql query that combines these two tables into one table which the report reads from, but this doesn't seem like best practice, or is it? Another approach would be to create some measures in the BI tool, I'm not a big fan of this approach because it seems to be least sustainable approach, and I'm unfamiliar with it.