4 Comments
User's avatar
Sanjeev's avatar

Amazing article !! I was looking for single table models for metrics, and this seems to be the easiest to build.

I am curious how would you handle cases where you want multiple dimensions in the cube ? Say segment and product category ?

Ergest Xheblati's avatar

Thanks. For multiple dimensions, the macro should be able to handle it. You add them to the JSON blob and expose them in the CTE that prepares the data. Here’s an example: https://github.com/Levers-Labs/SOMA-B2B-SaaS/blob/main/models/growth_accounting/base_metrics/ga_cube_contraction_revenue.sql

Ecil Teodoro's avatar

..."For orientation, anything to the left of a node is considered “downstream” and everything to the right of a node “upstream” like a river flowing left to right."...

I think it's the opposite.

Great article, btw.

Ergest Xheblati's avatar

Ah you’re quite right