Forum Discussion

Smason's avatar
Smason
Regular Visitor
5 years ago
Solved

How to Constraint Query to a time period

I am new to PowerQuerys and PowerBi, I am connecting to a ClearSCADA Database via ODBC but not getting any preview data. It keeps timing out. Can you advise how to contraint the default query below? ...
  • v-jingzhang's avatar
    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.

  • v-jingzhang's avatar
    v-jingzhang
    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.

    Reference: https://community.powerbi.com/t5/Power-Query/Connecting-to-ODBC-Datasource-using-SQL-Statement/m-p/493305

     

    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.