Forum Discussion
How to Constraint Query to a time period
- 5 years ago
Hi Smason
If you are experiencing the timeout error when connecting to an ODBC data source, you can add a parameter ConnectionTimeout in the first Source step code to extend the connection time. The default connection timeout value is 15 seconds. In below code, I modify it to 10 minutes.
Source = Odbc.DataSource("dsn=Test", [HierarchicalNavigation=true, ConnectionTimeout=#duration(0,0,10,0)]),
You can also set a larger value for CommandTimeout parameter to avoid the timeout error when querying the data. The default value is ten minutes.
See reference:
Odbc.DataSource - PowerQuery M | Microsoft Docs
Odbc.Query - PowerQuery M | Microsoft Docs
Regards,
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it. - 5 years ago
Hi Smason
If the database supports SQL query, you could add a SQL statement in the connection window or in Advanced Editor to filter the data based on a time period field in the database.
You could also first connect to the odbc data source to create a query. Then in Power Query Editor, click the down-arrow next to a time period column header and filter the rows per your need.
Hope this helps.
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.
Hi Smason
If you are experiencing the timeout error when connecting to an ODBC data source, you can add a parameter ConnectionTimeout in the first Source step code to extend the connection time. The default connection timeout value is 15 seconds. In below code, I modify it to 10 minutes.
Source = Odbc.DataSource("dsn=Test", [HierarchicalNavigation=true, ConnectionTimeout=#duration(0,0,10,0)]),
You can also set a larger value for CommandTimeout parameter to avoid the timeout error when querying the data. The default value is ten minutes.
See reference:
Odbc.DataSource - PowerQuery M | Microsoft Docs
Odbc.Query - PowerQuery M | Microsoft Docs
Regards,
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.
- Smason5 years agoRegular Visitor
Thanks much for your response.
Is there a way to edit the script to limit the amount of data being request to a time period, say for 1 year?
- v-jingzhang5 years agoCommunity Support
Hi Smason
If the database supports SQL query, you could add a SQL statement in the connection window or in Advanced Editor to filter the data based on a time period field in the database.
You could also first connect to the odbc data source to create a query. Then in Power Query Editor, click the down-arrow next to a time period column header and filter the rows per your need.
Hope this helps.
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.