Using dynamic union tables
Use case
Sometimes, you may have a lot of tables in a database, which actually relate to the same entity. For example, you can have “per client” tables with the same data, but related to different customers:elon_musk_table, john_doe_table, steve_jobs_table,
etc. In this case, it would make sense to create a single cube
for customers, which should be backed by a union table from all customers tables.
Data modeling
You can use thesql parameter to define a cube over an
arbitrary SQL query, e.g., a query that includes UNION or UNION ALL
operators:
Result
Queryingcount and name members of the dynamically defined customers cube
would result in the following generated SQL: