Learning to Conditionally Format Text Columns in Power BI


Data visualization is greatly enhanced when key information stands out. In Power BI, applying conditional formatting to numerical data is straightforward, but users often face a challenge when attempting to apply color rules based on text values (strings). This is frequently needed to categorize and visually separate distinct groups within a dataset, as illustrated by the desired outcome below.

Power BI conditional formatting based on text

Since Power BI’s built-in conditional formatting rules primarily rely on numeric inputs to define gradients or rule-based criteria, we must employ a simple but powerful workaround. This method involves creating an intermediary numeric column that acts as a proxy for the text values. This comprehensive, step-by-step guide demonstrates precisely how to achieve effective conditional formatting on a text column using this necessary technique.

Step 1: Importing and Preparing the Dataset

The first critical step in any data analysis workflow within Power BI is successfully importing the source data. For this demonstration, we will utilize a sample dataset containing information about various basketball players. This dataset includes a categorical text column, Team, which we intend to format visually to improve readability and analysis.

Ensure your data model is correctly loaded into the Power BI environment. Once imported, the initial dataset should look similar to the structure shown in the image below, featuring columns such as Player Name, Position, and the target text column, Team. Verification of data quality and structure at this stage is essential for smooth progression in the subsequent steps, especially since we rely on distinct text values for mapping.

Step 2: Creating a Numeric Proxy Column using DAX

As mentioned, conditional formatting rules require a numeric basis for rule definition. Therefore, the next crucial step is to create a new calculated column that assigns a unique numeric identifier to each distinct text value found in the Team column. This numeric column, which acts as a proxy, will serve as the foundation for our formatting logic, allowing us to circumvent the limitation of applying rules directly to strings.

To initiate the creation of this calculated column, navigate to the Table tools tab within the Power BI interface. From there, select the New column icon. This action opens the formula bar, allowing us to input a Data Analysis Expressions (DAX) formula. DAX is the expression language used by Power BI to define custom calculations, and it is perfectly suited for this conditional mapping task.

We will use the powerful DAX SWITCH function, which evaluates an expression against a list of specified values and returns a corresponding result. Enter the following formula into the formula bar. This code snippet maps specific team letters (‘A’, ‘B’, ‘C’) to corresponding numeric values (1, 2, 3), with any other unlisted value being defaulted to 4. This ensures every row in our dataset receives a quantifiable identifier.

New = SWITCH(
            'my_data'[Team],
            "A", 1,
            "B", 2,
            "C", 3,
            4
            )

Executing this formula successfully generates a new column named New, which now contains the required numeric representation of the categorical data in the Team column. This intermediary column is essential for the next step, where we define the visual formatting rules based on these newly assigned integers.

Step 3: Setting Up the Visualization

With the numeric proxy column created and validated, our focus shifts to the visualization layer. Navigate to the Report View in Power BI. We must first insert a visualization element that displays the data we wish to format. The most appropriate choice for this task is a standard Table visualization, as it allows precise control over individual column formatting and is ideal for showcasing detailed, row-level data.

Add the necessary fields to the Table visual, specifically including the Player Name and the original Team text column. Although the formatting rules will reference the New numeric column in the background, it is the original, user-facing Team column that will receive the visual styling. The visual should be structured clearly, displaying all required data points before applying any color rules.

Step 4: Applying Advanced Conditional Formatting Rules

This stage involves linking the coloring logic to the numeric proxy column we developed earlier. The core objective is to apply the formatting directly to the visible Team column, but base the rules entirely on the values present in the New numeric column. To begin, select the Table visual. In the Visualizations pane, locate the Columns section where the fields used in the table are listed.

Click the dropdown arrow next to the Team column. Hover over Conditional formatting, and then select Background color. This action opens the conditional formatting configuration dialog box. This dialog is critical because it allows us to specify the data field that dictates the color, which is where we will introduce our proxy column.

Within the configuration window, adjust the settings carefully to ensure the logic flows correctly:

  1. For the setting What field should we base this on?, select the newly created New column.
  2. For Summarization, choose Minimum. This is crucial as it instructs conditional formatting to evaluate the discrete numeric value (1, 2, 3, or 4) for each row, rather than attempting to aggregate the numbers across the entire column.
  3. Change the formatting style from the default ‘Color scale’ to Rules, as we need distinct colors for specific categories, not a continuous gradient.

You must now define distinct rules, mapping each numeric value in the New column to a specific background color. Since we have four possible numeric outcomes (1, 2, 3, and 4) defined by our DAX formula, we will create four corresponding rules. Ensure that you specify that the rule applies when the value “is greater than or equal to” and “is less than” the boundary numbers, setting the values as numbers rather than percentages, to accurately target the exact integer assigned to each team.

After clicking OK, the conditional formatting is immediately applied. The visual result is a highly effective data representation where background colors visually segment the teams, achieving the original objective of applying conditional formatting based on text values using a robust numeric proxy.

Power BI conditional formatting based on text

Additional Data Visualization Resources

Mastering advanced formatting techniques in Power BI is key to creating insightful reports and dashboards. This method of using a numeric proxy is versatile and highly effective and can be applied whenever categorical text data needs visual rules applied. Remember that while this tutorial focused on background color, the same principle can be extended to applying font color, data bars, or icons.

For users seeking to further enhance their data modeling and visualization capabilities, we recommend exploring tutorials that cover other essential tasks in the conditional formatting and DAX ecosystems:

  • Tutorials on calculating running totals in Power BI.
  • Guides to implementing dynamic titles and measures in Power BI reports.
  • Explanations of advanced filtering techniques using slicers and bookmarks.

These resources will help broaden your proficiency in utilizing the full potential of Power BI for complex data analysis.

Cite this article

Mohammed looti (2025). Learning to Conditionally Format Text Columns in Power BI. PSYCHOLOGICAL STATISTICS. Retrieved from https://statistics.arabpsychology.com/power-bi-apply-conditional-formatting-to-text-column/

Mohammed looti. "Learning to Conditionally Format Text Columns in Power BI." PSYCHOLOGICAL STATISTICS, 12 Nov. 2025, https://statistics.arabpsychology.com/power-bi-apply-conditional-formatting-to-text-column/.

Mohammed looti. "Learning to Conditionally Format Text Columns in Power BI." PSYCHOLOGICAL STATISTICS, 2025. https://statistics.arabpsychology.com/power-bi-apply-conditional-formatting-to-text-column/.

Mohammed looti (2025) 'Learning to Conditionally Format Text Columns in Power BI', PSYCHOLOGICAL STATISTICS. Available at: https://statistics.arabpsychology.com/power-bi-apply-conditional-formatting-to-text-column/.

[1] Mohammed looti, "Learning to Conditionally Format Text Columns in Power BI," PSYCHOLOGICAL STATISTICS, vol. X, no. Y, ص Z-Z, November, 2025.

Mohammed looti. Learning to Conditionally Format Text Columns in Power BI. PSYCHOLOGICAL STATISTICS. 2025;vol(issue):pages.

Download Post (.PDF)
Scroll to Top