Power Query is a powerful data transformation and analysis tool that is built into Microsoft Excel and Power BI. It allows users to connect to a wide range of data sources, including Salesforce Reports. In this article, we will explore how to use Power Query M Language code to connect to the Salesforce Reports data source from inside Power BI.
What is Power Query M Language Code?
Power Query M Language code is the scripting language used in Power Query to perform data transformations and manipulations. It is a functional programming language that supports a wide range of data manipulation functions, such as filtering, sorting, grouping, and aggregating data.
3. Enter your Salesforce login credentials and click on Connect.
4. Select the Salesforce Report you want to import into Power BI and click on Load.
This will import the selected Salesforce Report data into Power BI. However, sometimes we may need to perform additional data transformations or manipulations before loading the data into Power BI. This is where Power Query M Language code comes in handy.
Using Power Query M Language Code for Data Transformations
To perform data transformations using Power Query M Language code, we need to select the Transform Data option from the Home tab. This will open the Power Query Editor, where we can see the imported Salesforce Report data.
We can perform various data transformations by using the Query Editor interface, such as filtering, sorting, grouping, and aggregating data. However, sometimes we may need to perform more complex data transformations that are not available in the Query Editor interface. This is where Power Query M Language code can be used.
Power Query M Language code can be used to perform various data transformations, such as renaming columns, adding custom columns, and filtering data based on specific conditions. Let’s explore some examples of using Power Query M Language code for data transformations.
Renaming Columns
To rename a column in Power Query using M Language code, we can use the following syntax:
= Table.RenameColumns(
,{{,}})
For example, to rename the “Opportunity Name” column to “Name” in our Salesforce Report data, we can use the following code:
To add a custom column in Power Query using M Language code, we can use the following syntax:
= Table.AddColumn(
,,)
For example, to add a custom column “Status” that calculates the status of each opportunity in our Salesforce Report data based on the “Close Date” column, we can use the following code:
= Table.AddColumn(#”Renamed Columns”, “Status”, each if [Close Date] < DateTime.LocalNow() then "Closed" else "Open")
Filtering Data
To filter data in Power Query using M Language code, we can use the following syntax:
= Table.SelectRows(
,)
For example, to filter the Salesforce Report data to only show opportunities with a status of “Closed”, we can use the following code:
= Table.SelectRows(#”Added Custom Column”, each [Status] = “Closed”)
Conclusion
In this article, we explored how to use Power Query M Language code to connect to the Salesforce Reports data source from inside Power BI. We also looked at how to use Power Query M Language code to perform various data transformations, such as renaming columns, adding custom columns, and filtering data based on specific conditions. By using Power Query M Language code, we can perform complex data transformations and manipulations that are not available in the Query Editor interface.
Power BI Training Courses by G Com Solutions (0800 998 9248)
Mobile-optimized Reports Mobile reports are based on the regular web report which you will have already created, with the layout adapted and optimized for mobile. For example, adapting a four-column desktop layout into a single-column mobile one. Page-by-Page Layout Mobile reports must be designed on a page-by-page basis, with a separate design for each page,…
Part 4 (of 4): Creating a Report in Power BI Desktop 2 Click here to download the tutorial work files Power BI online training In the previous tutorial in this series, we discussed the use of the synoptic panel custom visual to build a car damage report; and we examined the completed report. In this…
In the digital age, organizations are generating vast amounts of data, and leveraging this data to gain valuable insights has become a crucial aspect of business operations. Power BI, a powerful business intelligence tool developed by Microsoft, enables businesses to visualize and analyze data effectively. Power BI reports are instrumental in presenting data-driven insights to stakeholders, helping them make informed decisions. However, traditional relationships in Power BI can sometimes limit the depth and flexibility of these reports.
Once you have configured your Power BI tenant, the next major aspect of Power BI which you need to address is the configuration of app workspaces. But what exactly are app workspaces and how do they differ from MyWorkspace, apps and template apps. Let’s start with workspaces. (If you are looking to learn Power BI,…
Power BI has emerged as a powerful tool for data visualization, enabling users to analyze and present complex information effectively. One of the key features that sets Power BI apart is its ability to create custom tooltips, which take data visualization to the next level. In this article, we will explore how you can master the art of custom tooltips in Power BI and unleash the full potential of your data.
In today’s data-driven world, businesses face the challenge of dealing with large volumes of data from various sources. The ability to uncover valuable insights from this data has become crucial for making informed decisions and gaining a competitive edge. Data discovery plays a pivotal role in this process by enabling organizations to explore, analyze, and understand their data. In this article, we will dive into the concept of data discovery and explore how TableProfile in Power Query can simplify the process, allowing users to extract powerful insights effortlessly.