Teradata database

As a Power BI user, you might need to connect to a Teradata database in order to retrieve data for your reports and dashboards. In this article, we will discuss how you can connect to a Teradata data source from within Power BI using Power Query M language code.

What is Power Query M Language Code?

Teradata database

Power Query M language code is a formula language used to create custom queries and transformations for importing data into Power BI. It is a functional programming language that allows you to manipulate data in a variety of ways, including filtering, merging, and grouping.

Connecting to the Teradata database

To connect to a Teradata database from within Power BI, you will first need to obtain the necessary credentials from your database administrator. These credentials typically include a server name, database name, username, and password.

Once you have obtained your credentials, you can use the following code to connect to your Teradata database:


Teradata database

let

Source = Teradata.Database(“ServerName”, “DatabaseName”, [Query=”SELECT FROM TableName”, CreateNavigationProperties=false]),

#”Filtered Rows” = Source{[ColumnName=”ColumnName”]}[Column1]

in

#”Filtered Rows”


In this code, replace “ServerName” and “DatabaseName” with your server and database names, respectively. You will also need to replace “TableName” and “ColumnName” with the name of the table and column you want to retrieve data from.

Retrieving Data from Teradata

Once you have connected to your Teradata database, you can retrieve data by modifying the “SELECT FROM TableName” query in the code above. For example, if you want to retrieve only the first 100 rows of data, you could modify the query as follows:


let

Source = Teradata.Database(“ServerName”, “DatabaseName”, [Query=”SELECT TOP 100 FROM TableName”, CreateNavigationProperties=false]),

#”Filtered Rows” = Source{[ColumnName=”ColumnName”]}[Column1]

in

#”Filtered Rows”


Alternatively, if you want to retrieve data from multiple tables, you can use the following code:


let

Source = Teradata.Database(“ServerName”, “DatabaseName”, [Query=”

SELECT

FROM Table1

UNION ALL

SELECT

FROM Table2

UNION ALL

SELECT

FROM Table3″, CreateNavigationProperties=false]),

#”Filtered Rows” = Source{[ColumnName=”ColumnName”]}[Column1]

in

#”Filtered Rows”


In this code, replace “Table1”, “Table2”, and “Table3” with the names of the tables you want to retrieve data from.

Conclusion

In conclusion, connecting to a Teradata database from within Power BI using Power Query M language code is a straightforward process. By following the steps outlined above, you can retrieve the data you need to create insightful reports and dashboards.

Power BI Training Courses by G Com Solutions (0800 998 9248)

Contact Us

    Subject

    Your Name (required)

    Company/Organisation

    Email (required)

    Telephone

    Training Course(s)

    Your Message

    Upload Example Document(s) (Zip multiple files)

    Similar Posts