How to Do Sentiment Analysis in Power BI

Cody Schneider8 min read

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.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

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:

  1. Power BI Desktop: This is the free application from Microsoft where you'll build your report. Make sure you have the latest version installed.
  2. 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.
  3. 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.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

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.

  1. Log in to your Azure portal.
  2. Click + Create a resource and search for "Language service." Select it and click Create.
  3. 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.
  4. Review and create the resource. Once deployed, navigate to it.
  5. 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.

  1. Open Power BI Desktop.
  2. In the Home ribbon, click Get Data and select Excel workbook (or whatever your data source is).
  3. Locate and open your ProductReviews.xlsx file.
  4. 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.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

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.

  1. In the Power Query Editor, go to the Home ribbon, click New Source > Blank Query.
  2. 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
  1. Important: Replace "YOUR_ENDPOINT_URL" with the actual Endpoint URL you copied from Azure. Don't delete the quotation marks.
  2. Replace "YOUR_API_KEY" with your Key.
  3. 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.

  1. Select your ProductReviews query.
  2. Go to the Add Column tab in the ribbon and click Invoke Custom Function.
  3. A new window will appear. Let’s fill it out:
  • New column name: Type a name like “Sentiment”.
  • Function query: Select fxGetSentiment from 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.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

Step 5: Load and Visualize Your Data

You've done the hard work transforming the data. Now let’s visualize it.

  1. In the Power Query Editor, go to the Home tab and click Close & Apply.
  2. 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 Sentiment column 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 ReviewText column to the Category field. Use your new Sentiment column 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 Sentiment data 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