The goal is to prepare a power BI report that provides historical data based on month-year selected by the user.
To get data for all available months, I am trying to do something like below
SELECT * FROM Employee
FOR SYSTEM_TIME
AS OF <<End of month>>
I want to run this query for every month available in the history table then union them all in a single table.
This way, I will be able to let the user select any month-year in power bi and filter this union table based on the selection.
The only question is that, how do I retrieve all available months from history table of a temporal table , so that I can iterate over them and run the above query for each?
One solution would be to create a view (or even run a select statement) that hard codes all the dates and unions them up.
SELECT * FROM Employee
FOR SYSTEM_TIME
AS OF '2010-01-01'
UNION ALL
SELECT * FROM Employee
FOR SYSTEM_TIME
AS OF '2010-02-01'
UNION ALL
SELECT * FROM Employee
FOR SYSTEM_TIME
AS OF '2010-03-01'
This is the 'brute force' method.
It's probably possible to do something much smarter in M (the import language in Power BI) but I'm unable to find a good example
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.