How to Do Sentiment Analysis in Power BI
Ever wish you could just know how customers are feeling about your products without reading thousands of individual reviews? Understanding customer sentiment - whether they're happy, frustrated, or neutral - is a goldmine for improving products and services. This article will show you exactly how to perform sentiment analysis directly within Power BI, turning massive volumes of qualitative feedback into clear, actionable, and visual insights.
What Exactly Is Sentiment Analysis?
Sentiment analysis, sometimes called opinion mining, is the process of using technology to identify and categorize opinions expressed in a piece of text. In simple terms, it determines whether a writer's attitude towards a particular topic is positive, negative, or neutral. For business, this technique is incredibly valuable because it quantifies subjective feedback.
Instead of manually tagging every customer comment, you can automatically process:
- Product reviews on your e-commerce site
- Social media comments and mentions
- Customer support tickets or chat logs
- Responses from open-ended survey questions
By connecting this capability to Power BI, you don’t just get a list of sentiments, you can visualize trends, filter feedback by product or region, and discover insights you’d otherwise miss.
Getting Started: What You'll Need
Setting this up is more accessible than you might think. Before we begin, make sure you have the following ready:
- Power BI Desktop: This is the free application from Microsoft where you'll build your report. Make sure you have the latest version installed.
- A Dataset with Text: This can be an Excel file, a CSV, or a database connection that contains the customer feedback you want to analyze. For this tutorial, we’ll use a simple table of product reviews with a column named
ReviewText. - An Azure Account: Sentiment analysis in Power BI relies on Azure AI Services (formerly known as Cognitive Services). You will need an Azure subscription to create a "Language service" resource. If you're new to Azure, you can often start with a free trial or a free tier, which is perfect for experimenting.
Don’t be intimidated by the mention of Azure. The setup is quite straightforward, and we'll walk through exactly what you need to do.
Step-by-Step: Sentiment Analysis from Scratch
Let's go through the entire process, from getting your data into Power BI to building insightful visualizations based on sentiment. Assume you have an Excel sheet named ProductReviews.xlsx with columns like ReviewID and ReviewText.
Step 1: Set Up Your Azure Language Service Resource
Before touching Power BI, you need the engine that will perform the analysis. This lives in Azure.
- Log in to your Azure portal.
- Click + Create a resource and search for "Language service." Select it and click Create.
- Fill out the required information, such as your subscription, resource group (create a new one if you don't have one), region, and a unique name for your resource (e.g.,
MyCompanySentiment). Choose a pricing tier - the free tier (F0) is great for getting started. - Review and create the resource. Once deployed, navigate to it.
- In the menu on the left, find and click on Keys and Endpoint. You will need two pieces of information from this screen for Power BI: one of the Keys and the Endpoint URL. Copy these to a secure place like a text file for now.
Security Tip: Never share your API keys or paste them into publicly accessible documents. For production reports, it's best to use Power BI parameters to manage these credentials.
Step 2: Load Your Text Data into Power BI
Now, let's open Power BI and get our review data ready.
- Open Power BI Desktop.
- In the Home ribbon, click Get Data and select Excel workbook (or whatever your data source is).
- Locate and open your
ProductReviews.xlsxfile. - The Navigator window will appear. Select the worksheet containing your reviews and click Transform Data. This will open the Power Query Editor, which is where we will do all our prep work.
You should now see your review data in the Power Query window. Before moving on, a quick data health check is a good idea. Make sure your ReviewText column doesn't have too many blank or null values, as these will cause errors during the analysis.
Step 3: Create a Custom Function in Power Query
To communicate with the Azure Language Service, we need to create a custom function in Power Query. This sounds technical, but it’s mostly a copy-and-paste exercise. This function will take our review text, send it to Azure, and bring back the sentiment result.
- In the Power Query Editor, go to the Home ribbon, click New Source > Blank Query.
- In the formula bar, paste the following M code. But remember, don't write the formula from scratch yourself. All you need is to find it by following Power BI tutorial docs online, which will guide you on where to place your keys and endpoints:
(text) =>
let
// Create the JSON payload for the API
Json_body = Text.FromBinary(Json.FromValue(
[
documents =
{
[
id = "1",
language = "en",
text = text
]
}
]
)),
// Call the Azure AI Language Service
AzureAIResponse = Web.Contents(
"YOUR_ENDPOINT_URL" & "/text/analytics/v3.0/sentiment",
[
Headers=[
#"Ocp-Apim-Subscription-Key" = "YOUR_API_KEY",
#"Content-Type"="application/json"
],
Content=Text.ToBinary(Json_body)
]
),
// Decode the JSON response
ParsedResult = Json.Document(AzureAIResponse),
SentimentScore = ParsedResult[documents]{0}[sentiment],
// Return the resulting sentiment
Result = SentimentScore
in
Result- Important: Replace
"YOUR_ENDPOINT_URL"with the actual Endpoint URL you copied from Azure. Don't delete the quotation marks. - Replace
"YOUR_API_KEY"with your Key. - On the right pane, rename the blank query to something memorable, like
fxGetSentiment.
You’ve just built an API-calling function! Let's now use it.
Step 4: Invoke the Function to Get Sentiment
Navigate back to your primary data query (the one with your product reviews). Now, we will add a new column that runs our function on every review.
- Select your
ProductReviewsquery. - Go to the Add Column tab in the ribbon and click Invoke Custom Function.
- A new window will appear. Let’s fill it out:
- New column name: Type a name like “Sentiment”.
- Function query: Select
fxGetSentimentfrom the dropdown list. - text (optional): In the dropdown menu for the parameter, select the ReviewText column since it's what we want to process.
Click OK. Depending on how many reviews you have, Power Query may take a moment to process. It is sending each row's text to Azure and waiting for a response.
If you see a privacy-related pop-up, choose to connect publicly if you're comfortable or configure the privacy levels appropriately for your organization's data policies.
Once finished, you’ll have a new Sentiment column populated with values like “positive”, “negative”, or “neutral”. Success!
Pro Tip: To get confidence scores (e.g., how confident Azure is that a review is 95% positive), you can modify the custom function's last line to return more data from the ParsedResult. This lets you analyze nuanced sentiment levels.
Step 5: Load and Visualize Your Data
You've done the hard work transforming the data. Now let’s visualize it.
- In the Power Query Editor, go to the Home tab and click Close & Apply.
- Power BI will load the data into its data model. Once done, you are in the Report View.
Here are a few visualizations to build for immediate impact:
Overall Sentiment Breakdown
- Choose a Donut chart or Pie chart from the Visualizations pane.
- Drag the
Sentimentcolumn to the Legend and Values fields. - Voila! You now have a high-level view of your customer sentiment distribution.
Word Cloud of Frequent Terms
- Install the "Word Cloud" custom visual from the AppSource marketplace if you don't have it.
- Add it to your report canvas.
- Drag the
ReviewTextcolumn to the Category field. Use your newSentimentcolumn as a slicer to see the most common words in positive vs. negative reviews. This can instantly highlight what customers love (“fast shipping,” “great quality”) versus what they dislike (“poor battery,” “difficult setup”).
Sentiment Table by Product Category (if available)
- Create a Matrix.
- Put any product/category column you have on the Rows.
- Place your new
Sentimentdata as the Columns.
Final Thoughts
Turning unstructured text into structured insights is a superpower for any business, and this process brings that power right into your Power BI reports. By connecting to Azure's Language service, you can move beyond simple star ratings and truly understand the "why" behind your customer feedback, enabling you to build better products and foster stronger customer relationships. With Power BI as the visualization layer, you don't have to keep repeating the work for every customer review going forward.
We know that getting your hands dirty with M code and configuring Azure services isn’t something everyone has time for, which is why we’ve built a different approach. With Graphed, we handle the complex setup and connections to all your scattered sales and marketing tools - like Salesforce, Shopify, and social media platforms. We simplify the entire process so you turn data into decisions by asking simple natural language questions instead of having to watch tutorials explaining how to use business intelligence software or resources that not everybody can learn.
Related Articles
What SEO Tools Work with Google Analytics?
Discover which SEO tools integrate seamlessly with Google Analytics to provide a comprehensive view of your site's performance. Optimize your SEO strategy now!
Looker Studio vs Metabase: Which BI Tool Actually Fits Your Team?
Looker Studio and Metabase both help you turn raw data into dashboards, but they take completely different approaches. This guide breaks down where each tool fits, what they are good at, and which one matches your actual workflow.
How to Create a Photo Album in Meta Business Suite
How to create a photo album in Meta Business Suite — step-by-step guide to organizing Facebook and Instagram photos into albums for your business page.