Sybase.Database

D

T

The M Code Behind the Power Query M function Sybase.Database

What is Sybase.Database?

Sybase is a relational database management system that is used by many organizations to manage their data. The Sybase.Database function in Power Query allows users to connect to and extract data from Sybase databases.

The M Code Behind Sybase.Database

When you use the Sybase.Database function in Power Query, the M code that is generated behind the scenes is actually quite simple. Here’s an example of the M code that is generated when you use the Sybase.Database function to connect to a Sybase database:


let

Source = Sybase.Database("[Server]", "[Database]", [Query="SELECT FROM [Table]"]),

#"Filtered Rows" = Table.SelectRows(Source, each ([Column1] = "Value")),

#"Sorted Rows" = Table.Sort(#"Filtered Rows",{{"Column2", Order.Ascending}})

in

#"Sorted Rows"


Let’s break down each section of this code to understand what it does.

Step 1: Connect to the Sybase Database

The first step in the M code behind the Sybase.Database function is to connect to the Sybase database. This is done using the following code:


let

Source = Sybase.Database("[Server]", "[Database]", [Query="SELECT FROM [Table]"]),


In this code, you specify the server name and database name that you want to connect to. You can also specify an optional SQL query to retrieve specific data from the database.

Step 2: Filter the Data

The next step in the M code is to filter the data that you have retrieved from the Sybase database. This is done using the following code:


#"Filtered Rows" = Table.SelectRows(Source, each ([Column1] = "Value")),


In this code, you specify the column name and value that you want to filter by. This will return a table with only the rows that match the specified criteria.

Step 3: Sort the Data

The final step in the M code is to sort the data that you have filtered. This is done using the following code:


#"Sorted Rows" = Table.Sort(#"Filtered Rows",{{"Column2", Order.Ascending}})


In this code, you specify the column name and sort order that you want to use. This will return a table with the data sorted based on the specified criteria.

In conclusion, the M code behind the Power Query M function Sybase.Database is actually quite simple. It consists of just a few lines of code that allow users to connect to and extract data from Sybase databases. By understanding the M code behind this function, users can write their own custom formulas to transform data in a more efficient and effective way.

Power Query and M Training Courses by G Com Solutions (0800 998 9248)

Upcoming Courses

Contact Us

    Subject

    Your Name (required)

    Company/Organisation

    Email (required)

    Telephone

    Training Course(s)

    Your Message

    Upload Example Document(s) (Zip multiple files)