Amazon Redshift

Power BI is a popular business intelligence tool that allows users to create interactive visualizations and reports. It also allows users to connect to a variety of data sources, including Amazon Redshift. Amazon Redshift is a cloud-based data warehousing solution that allows users to store and analyze large amounts of data.

Amazon Redshift

In order to connect to an Amazon Redshift data source from inside Power BI, users must use Power Query and the M language. Power Query is a data connectivity and data preparation tool that allows users to extract, transform, and load data from a variety of sources. The M language is a functional programming language that is used to create custom functions and transform data.

Setting up the Amazon Redshift Data Source

Before connecting to an Amazon Redshift data source from inside Power BI, users must first set up the data source. This involves creating an Amazon Redshift cluster, creating a database, and creating tables. Once the data source has been set up, users can then connect to it from inside Power BI.

Connecting to the Amazon Redshift Data Source

To connect to an Amazon Redshift data source from inside Power BI, users must first open Power BI Desktop. They should then click on the “Get Data” button in the Home tab of the ribbon. From here, they should select “Amazon Redshift” from the list of available data sources.

Users will then be prompted to enter their Amazon Redshift server name, database name, and credentials. Once these details have been entered, users can then click on the “Connect” button to connect to the data source.

Creating a Query to Retrieve Data

Amazon Redshift

Once connected to the Amazon Redshift data source, users can create a query to retrieve data. To do this, they should click on the “Edit Queries” button in the Home tab of the ribbon. They should then click on the “New Source” button and select “Blank Query” from the list of available options.

Users can then click on the “Advanced Editor” button in the View tab of the ribbon. This will open the M code editor, where users can enter custom M language code to retrieve data. The following M code can be used to retrieve data from an Amazon Redshift data source:


let

Source = Redshift.Database(“server”, “database”, [Query=”SELECT FROM table”]),

#”Retrieved Rows” = Source{[Schema=”public”,Item=”table”]}[Data]

in

#”Retrieved Rows”


This code connects to the specified Amazon Redshift server and database, and retrieves all rows from the specified table. Users can modify the query to retrieve specific columns or filter the data as needed.

Transforming Data

Once data has been retrieved from an Amazon Redshift data source, users can then transform the data as needed. Power Query provides a number of transformation options, such as filtering, sorting, and grouping data.

Users can also use custom M language code to create custom transformations. For example, the following M code can be used to pivot data:


let

Source = Redshift.Database(“server”, “database”, [Query=”SELECT FROM table”]),

#”Retrieved Rows” = Source{[Schema=”public”,Item=”table”]}[Data],

#”Pivoted Column” = Table.Pivot(#”Retrieved Rows”, List.Distinct(#”Retrieved Rows”[Column]), “Column”, “Value”)

in

#”Pivoted Column”


This code pivots the data based on the values in the specified column. Users can modify the query to pivot data based on different columns or values.

Conclusion

Connecting to an Amazon Redshift data source from inside Power BI can be done using Power Query and the M language. Users can retrieve data, transform it as needed, and create interactive reports and visualizations. With these tools, users can gain valuable insights into their data and make informed business decisions.

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