- •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
Exploring artificial intelligence insights 143
You can see how, with a few easy steps, you can manipulate a data structure that would be difficult to manage with other tools. This means that end users can push themselves to do advanced data preparation without the need to request changes at data source level.
The logic on JSON parsing applies to the XML structure as well.
Exploring artificial intelligence insights
Power Query allows us to enrich data with a data engineering approach. It also provides us with artificial intelligence (AI) tools to access cognitive services, which are pre-trained machine learning (ML)models provided by Microsoft, usually used by data scientists and app developers to apply cognitive capabilities to reading and interpreting data.
In this recipe, you will explore how to leverage these features in order to run, with a no-code approach, consistent text analysis, thanks to the use of cognitive services.
Getting ready
For this recipe, you need to have Power BI Desktop running on your machine. You need to download the following file in a local folder:
• IMDB-Dataset CSV file with movie reviews data
In this example, we will refer to the C:\Data folder.
In order to access cognitive services resources, you need to have a running Power BI Premium capacity.
144 Reshaping Your Data
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.
2.Browse to your local folder where you downloaded the IMDB-Dataset CSV file and open it. The following window with a preview of the data will pop up. Click on
Transform Data:
Figure 4.54 – CSV data preview
Exploring artificial intelligence insights 145
3.Browse to the Home tab and click on Use First Rows as Headers. Select the first column, review, where you can find movie reviews, browse to the Add Column tab, and click on Text Analytics in order to see the following window displayed:
Figure 4.55 – Detect language
Now, click on Detect language, select the review column and click on OK. This way, you will be applying the text analytics function to detect the language type of the selected column.
4.You will see two new columns, Detect language.Detected Language Name and Detect language.Detected Language ISO Code, with information about the language detected:
Figure 4.56 – Detect language output
146Reshaping Your Data
5.Click again on Text Analytics and click now on Extract key phrases:
Figure 4.57 – Extract key phrases
6. You can see the following two columns with key words for every single review:
Figure 4.58 – Extract key phrases output
Exploring artificial intelligence insights 147
As well as text analytics services, you can also do analysis on images using vision services. If you have a column with links redirecting to images, you can enrich that content by applying image tags.
Moreover, you can recall custom machine learning models developed on Azure Machine Learning by data scientists. The idea is to have Power Query features that allow business users and analysts to collaborate with more technical users, such as data engineers and data scientists.
Artificial intelligence insights can be seen as the entry point to recall pre-calculated artificial intelligence services such as cognitive services and custom ML models developed on Azure Machine Learning.
5
Combining Queries for Efficiency
Business analysts need to perform complex transformations that usually involve a combination of multiple queries. They often need to join data horizontally or to append tables.
With different ways of combining data, you can transform and model tables in order to optimize the information included. By leveraging different methods, you can perform merge and join transformations in order to enrich data or append and combine queries to scale and increase data volume automatically. The main aim is to create queries with relevant data that can serve different purposes, such as reporting, loading to Dataverse through Power Apps, or loading to Azure Data Lake to make this data available for other applications.
In this chapter, you will explore the following combining options within Power Query:
•Merging queries
•Joining methods
•Appending queries
•Combining multiple files
•Using the Query Dependencies view