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?

 

let
Source = Odbc.DataSource("dsn=Test", [HierarchicalNavigation=true]),
Opc_Schema = Source{[Name="Opc",Kind="Schema"]}[Data],
COpcAlgPoint_Table = Opc_Schema{[Name="COpcAlgPoint",Kind="Table"]}[Data]
in
COpcAlgPoint_Table

  • 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.

  • 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.

     

4 Replies

  • v-jingzhang's avatar
    v-jingzhang
    Community Support

    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.

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

        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.

         

  • Smason's avatar
    Smason
    Regular Visitor

    This is the error below that is being experience.

     

    DataSource.Error: ODBC: ERROR [HY000] [Schneider Electric][Geo SCADA Expert database driver]Table CAlarm not found
    Details:
    DataSourceKind=Odbc
    DataSourcePath=dsn=test
    OdbcErrors=[Table]