DJHarris71
New Member
- Joined
- May 19, 2009
- Messages
- 44
Hello. I need to pull data from a same formatted table on the same server from different databases with a SQL query, but the tables in the server have 3 years of data, and I only want 3 months.
I know that for one table I can do this:
But this limits me to one database.
/
I also know I can do this:
The problem here is that the command 'Data = Table{[Schema="dbo",Item="RawWorkStation"]}[Data],' still pulls all 3 years, which defeats the purpose.
/
I also know that I can put the these in a function, Such as:
However, this method forces my query into a 'Dynamic' mode. Which then does not allow me to do a refresh schedule in the Power BI Cloud Service, which is required.
So, question 1 is: How can I do the above without this 'Dynamic' mode happening?? If you can't then see below..
Interestingly, if I do it this way, it does not force it into a 'Dynamic' mode, but it still pulls 3 years of data on the Data step.
This is the only working solution I have, but I need to transform some of these fields (such as divide by 60 or 100), and these are things I can do right in the query. This is more efficient than doing this in the Power Query M transformation as each command creates a saved table variable, which is more memory usage, and is chargeable by MS, and just slower in general.
So the question here is: Is there way to add a query statement to this method?
Thanks,
Doug
I know that for one table I can do this:
VBA Code:
Source = Sql.Database("Server", "Database", [Query="Query with FROM Table WHERE [DATE] >= DATEADD(DAY,-90, GETDATE())"])
/
I also know I can do this:
Code:
Source = Sql.Databases("server"),
Table = Source{[Name="Database"]}[Data],
Data = Table{[Schema="dbo",Item="Table"]}[Data],
Data90days = Table.SelectRows(Data, each Date.IsInPreviousNDays([Date], 90))
/
I also know that I can put the these in a function, Such as:
Code:
GetTable = (Database as text) as table =>
let
Source = Sql.Database("Server", Database, [Query="Query with FROM Table WHERE [DATE] >= DATEADD(DAY,-90, GETDATE())"])
in
Source
So, question 1 is: How can I do the above without this 'Dynamic' mode happening?? If you can't then see below..
Interestingly, if I do it this way, it does not force it into a 'Dynamic' mode, but it still pulls 3 years of data on the Data step.
Code:
Source = Sql.Databases("server"),
GetTable = (Database text) as table =>
let
Table = Source{[Name=Database]}[Data],
Data = Table{[Schema="dbo",Item="Table"]}[Data],
Data90days = Table.SelectRows(Data, each Date.IsInPreviousNDays([Date], 90))
in
Source
So the question here is: Is there way to add a query statement to this method?
Thanks,
Doug