Text Analytics in Microsoft Azure and Power BI

Kumail Raza
4 min readJul 18, 2018

Text analysis is about examining text from different group of people and identifying patterns of what people are talking about, their views, key-words, interests and wants.

Types of Text Analytics

There are many kinds of text analysis as you can see in picture;

Types of Text Analytics

The 3 of the text analytics services provided by Microsoft Azure Cognitive Services are;

Sentiment Analysis

Find out what users think about your products or services. You can score the overall sentiment of the text.

Key-phrase Extraction

Automatically extract key phrases from the text to quickly identify the main points.

Language Detection

Determine what language a piece of text is written in-from 120 supported languages.

In this article, we are going to see the process of using Microsoft Azure Cognitive Services and Power BI to identify key phrase from data.

Requirements

It is assumed you already have Microsoft Azure trial or paid subscription and Microsoft Power BI installed on Desktop.

10 Simple and easy to do steps;

Steps

  1. Navigate to Microsoft Azure Portal.
Microsoft Azure Portal

2. Create a new Resource and select Text Analytics.

3. The system will create an endpoint URL and API keys to use this service.

Now our Azure Web Service is Ready with End Point URL and API Key.

4. Import your data into Power BI. I have used sample data and imported it using Power Query into Power BI.

5. Now create another blank query and paste M language code that will use the Azure web service endpoints and api keys we created earlier.

The code is;

`(text) =>let
apikey =”Enter Your API Key Here”,
endpoint =”Enter Your End Point Here”,
jsontext =Text.FromBinary(Json.FromValue(Text.Start(Text.Trim(text), 5000))),
jsonbody =”{ documents: [ { language: “”en””, id: “”0"”, text: “ & jsontext & “} ] }”,
bytesbody =Text.ToBinary(jsonbody),
headers = [#”Ocp-Apim-Subscription-Key” = apikey],
bytesresp =Web.Contents(endpoint, [Headers=headers, Content=bytesbody]),
jsonresp =Json.Document(bytesresp),
keyphrases =Text.Lower(Text.Combine(jsonresp[documents]{0}[keyPhrases], “, “))
in keyphrases `

6. When you are done with the code, you will see a query created like this;

7. Now we need a custom column to invoke a function. It can be created from the “Add Column” tab and selecting “Custom Column Function”.

8. There, we will name the column, select the query we created with M code and select the column that has the text that we want to analyze.

9. And it will add a column that has the key-phrases extracted for each row of the data.

10. This is the output of key-phrases extracted from the data :)

That’s It. I hope now you know more about text analytics in Microsoft Azure and Power BI 😊. May you know someone who would find this article informative, please share!, follow me on Twitter or visit my website and stay tuned.

--

--

Kumail Raza

Data Engineer and Architect/ Instructor and Facilitator on Microsoft Fabric and Udemy