- •Contributors
- •Table of Contents
- •Preface
- •Technical requirements
- •Installing a Power BI gateway
- •Getting ready
- •How it works
- •Authentication to data sources
- •Getting ready
- •How it works
- •Main challenges that Power Query solves
- •Getting ready
- •Technical requirements
- •Getting data and connector navigation
- •Getting ready
- •Creating a query from files
- •Getting ready
- •How it works...
- •Creating a query from a folder
- •Getting ready
- •How it works...
- •Creating a query from a database
- •Getting ready
- •How it works...
- •Creating a query from a website
- •Getting ready
- •How it works...
- •Technical requirements
- •Exploring Power Query Editor
- •Getting ready
- •Managing columns
- •Getting ready
- •Using data profiling tools
- •Getting ready
- •Using Queries pane shortcuts
- •Getting ready
- •Using Query Settings pane shortcuts
- •Getting ready
- •Using Schema view and Diagram view
- •Getting ready
- •Technical requirements
- •Formatting data types
- •Getting ready
- •Using first rows as headers
- •Getting ready
- •Grouping data
- •Getting ready
- •Unpivoting and pivoting columns
- •Getting ready
- •Filling empty rows
- •Getting ready
- •Splitting columns
- •Getting ready
- •Extracting data
- •Getting ready
- •Parsing JSON or XML
- •Getting ready
- •Exploring artificial intelligence insights
- •Getting ready
- •Technical requirements
- •Merging queries
- •Getting ready
- •Joining methods
- •Getting ready
- •Appending queries
- •Getting ready
- •Combining multiple files
- •Getting ready
- •Using the Query Dependencies view
- •Getting ready
- •Technical requirements
- •Setting up parameters
- •Getting ready
- •Filtering with parameters
- •Getting ready
- •Folding queries
- •Getting ready
- •Leveraging incremental refresh and folding
- •Getting ready
- •Disabling query load
- •Getting ready
- •Technical requirements
- •Using M syntax and the Advanced Editor
- •Getting ready
- •Using M and DAX – differences
- •Getting ready
- •Using M on existing queries
- •Getting ready
- •Writing queries with M
- •Getting ready
- •Creating tables in M
- •Getting ready
- •Leveraging M – tips and tricks
- •Getting ready
- •Technical requirements
- •Adding columns from examples
- •Getting ready
- •Adding conditional columns
- •Getting ready
- •Adding custom columns
- •Getting ready
- •Invoking custom functions
- •Getting ready
- •Clustering values
- •Getting ready
- •Technical requirements
- •Using Power BI dataflows
- •Getting ready
- •Centralizing ETL with dataflows
- •Getting ready
- •Building dataflows with Power BI Premium capabilities
- •Getting ready
- •Understanding dataflow best practices
- •Getting ready
- •Technical requirements
- •Exploring diagnostics options
- •Getting ready
- •Managing a diagnostics session
- •Getting ready
- •Designing a report with diagnostics results
- •Getting ready
- •There's more…
- •Using Diagnose as a Power Query step
- •Getting ready
- •Other Books You May Enjoy
- •Index
Disabling query load 223
Once you publish the model on the Power BI service, you will be able to trigger the refresh from there and update data quickly. Query folding is key to achieve this functionality because when you send the refresh query to the source, you will be applying a filter that will be included in the statement sent to the source.
Disabling query load
Queries' loads can be heavy and sometimes refreshing some tables can impact negatively on performance. This is why it is important to know what data is concretely needed
for end users. It is common that you will need some queries just for transformations in Power Query, but you won't need them in the final model. In this recipe, we will see
how you can use some queries for enriching data needed for reporting and how you can disable the loading of this supporting table in order to reduce the impact on performance and refreshing.
Getting ready
For this recipe, you need to download the following files:
•The FactInternetSales CSV file
•The DimTerritory CSV file
In this example, we will refer to the C:\Data folder.
224 Optimizing Power Query Performance
How to do it…
Once you open your Power BI Desktop application, you are ready to perform the following steps:
1. Click on Get data and select the Text/CSV connector.
Figure 6.59 – Text/CSV connector
2.Browse to your local folder where you downloaded the FactInternetSales.csv file and open it. The following window with a preview of the data will pop up. Click on
Transform Data.
Disabling query load 225
Figure 6.60 – CSV data preview
3.Repeat the previous two steps and load the DimTerritory.csv file.
4.Select DimTerritory in the Queries pane, browse to the Home tab, and click on the
Merge Queries button.
Figure 6.61 – Merge Queries button
226Optimizing Power Query Performance
5.The Merge window will pop up. Select FactInternetSales as the table to merge with DimTerritory and select the SalesTerritoryKey column from both tables. Select Left Outer (all from first, matching from second) and click on OK.
Figure 6.62 – Merge window
Disabling query load 227
6.Click on the expand button on the right side of the FactInternetSales column. Flag Aggregate, select Sum of TotalProductCost and Sum of SalesAmount, and remove the flag from Use original column name as prefix, as shown in the following screenshot:
Figure 6.63 – Expanding columns
228Optimizing Power Query Performance
7.You should see the two newly added columns in the DimTerritory query.
Figure 6.64 – Newly added columns
8.Rename the DimTerritory query to Sales geography since it will be the table that we will load in the data model.
Figure 6.65 – Renaming queries
9.Right-click on FactInternetSales in the Queries pane and observe how, if you load the queries with the current setting, you will load both of the queries because they have Enable load flagged.
Disabling query load 229
Figure 6.66 – Enable load button
10.If you click on Enable load, you will remove the flag and you will see that the name of the query will turn into italics, which means that if you load the queries with these settings, you will only be loading the Sales geography query and not FactInternetSales, which in this case was used only to enrich the other query.
Figure 6.67 – Enable load button disabled
230 Optimizing Power Query Performance
While using Power Query and performing data transformation steps, many queries will be used to enrich others and there is no concrete need to load them all. This will leave you with poor performance and high loading and refresh times and will increase the complexity of the data model.
By disabling the loading of some queries, you won't lose the transformations applied, such as the merge in this recipe, but you won't need to load a high-volume table.
7
Leveraging the M Language
Power Query is based on M language, which stands for Power Query Formula Language. Every time you perform a Power Query step, you are essentially writing
M code. You can leverage the UI to transform your data without learning any M language at all but gaining an understanding of it could help you to customize even more Power Query transformations and perform quick corrections that are not possible with
the UI only.
In this chapter, we will give an outline of M coding, explaining its differences from Data Analysis Expression (DAX) language (a familiar language to Power BI users), and you will see how to use M code on existing queries and how to create queries from scratch.
You will explore M coding examples through the following recipes:
•Using M syntax and the Advanced Editor
•Using M and DAX – differences
•Using M on existing queries
•Writing queries with M
•Creating tables in M
•Leveraging M – tips and tricks