Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
PBIfolks
New Member

Apply Conditional Formatting to a Column and am seeking assistance

Hello All, I would like to apply conditional formatting to a column and am seeking assistance.

 

My goal is to enable users to select a color that will automatically be applied to a column header in Power BI, based on data sourced from Excel. For instance, if a user selects '1', the color should be green; for '2', blue; and for '3', red. Please be aware that the report is updated monthly. Therefore, as users change values in Excel each month, these changes should be dynamically reflected in Power BI. I'm facing a challenge with applying conditional formatting to a column instead of a row. If you have a more effective way to model the data, your suggestions would be greatly appreciated. My brain is a bit fatigued, just want to see column conditional formatted.😁

 

Can anyone provide a solution for this? I have included a screenshot below for better clarity.

PBI_CC.png

 

 

1 ACCEPTED SOLUTION
123abc
Community Champion
Community Champion

I see, it seems like you're specifically looking to highlight column headers based on values from Excel, rather than rows. Unfortunately, Power BI's native conditional formatting options may not directly support this functionality for column headers.

However, there's an alternative approach you can try to achieve a similar outcome:

  1. Create a DAX Measure:

    • Instead of directly formatting the column headers, you can create a DAX measure that dynamically changes its background color based on the selected value.
  2. Use a Card Visual:

    • Place a card visual at the top of your report canvas.
    • Set the DAX measure as the value for this card visual.
    • Adjust the formatting of the card visual to resemble a column header.

Here's a simplified version of how you might implement this:

Step 1: Create a DAX Measure

Let's assume you have a table named ColorMapping with columns Value and Color. Create a DAX measure that retrieves the color based on the selected value:

 

HeaderColor =
VAR SelectedValue = SELECTEDVALUE('YourTable'[YourValueColumn])
RETURN
SELECTEDVALUE(
RELATED('ColorMapping'[Color]),
SWITCH(
SelectedValue,
1, "#00FF00", // Green
2, "#0000FF", // Blue
3, "#FF0000", // Red
"#FFFFFF" // Default color
)
)

 

Step 2: Use a Card Visual

  • Drag a card visual onto your report canvas.
  • Assign the HeaderColor measure to the value field of the card visual.
  • Adjust the formatting of the card visual to match your column header style.
  • Position the card visual at the top of your report to act as a dynamic column header.

With this setup, as users change the value selection in your report, the card visual at the top will dynamically change its background color based on the selected value, effectively simulating conditional formatting for the column header.

While this solution doesn't directly format the column headers, it provides a workaround to achieve similar visual effects within Power BI.

 

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.

 

In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.

View solution in original post

3 REPLIES 3
PBIfolks
New Member

Already tried similar DAX not working, it will only highlight rows unless i’m missing anything in your solution which you can specifically like to highlight, appreciate for your suggestion.

123abc
Community Champion
Community Champion

I see, it seems like you're specifically looking to highlight column headers based on values from Excel, rather than rows. Unfortunately, Power BI's native conditional formatting options may not directly support this functionality for column headers.

However, there's an alternative approach you can try to achieve a similar outcome:

  1. Create a DAX Measure:

    • Instead of directly formatting the column headers, you can create a DAX measure that dynamically changes its background color based on the selected value.
  2. Use a Card Visual:

    • Place a card visual at the top of your report canvas.
    • Set the DAX measure as the value for this card visual.
    • Adjust the formatting of the card visual to resemble a column header.

Here's a simplified version of how you might implement this:

Step 1: Create a DAX Measure

Let's assume you have a table named ColorMapping with columns Value and Color. Create a DAX measure that retrieves the color based on the selected value:

 

HeaderColor =
VAR SelectedValue = SELECTEDVALUE('YourTable'[YourValueColumn])
RETURN
SELECTEDVALUE(
RELATED('ColorMapping'[Color]),
SWITCH(
SelectedValue,
1, "#00FF00", // Green
2, "#0000FF", // Blue
3, "#FF0000", // Red
"#FFFFFF" // Default color
)
)

 

Step 2: Use a Card Visual

  • Drag a card visual onto your report canvas.
  • Assign the HeaderColor measure to the value field of the card visual.
  • Adjust the formatting of the card visual to match your column header style.
  • Position the card visual at the top of your report to act as a dynamic column header.

With this setup, as users change the value selection in your report, the card visual at the top will dynamically change its background color based on the selected value, effectively simulating conditional formatting for the column header.

While this solution doesn't directly format the column headers, it provides a workaround to achieve similar visual effects within Power BI.

 

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.

 

In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.

123abc
Community Champion
Community Champion

To achieve conditional formatting in Power BI based on values from Excel, you can follow these steps:

  1. Load Data from Excel: Import your Excel data into Power BI. Ensure that the column containing the values you want to use for conditional formatting is included in your dataset.

  2. Create a Measure for Conditional Formatting: Create a measure that maps the values in your column to colors. You can use DAX (Data Analysis Expressions) for this purpose.

    For example, assuming your column is named "ValueColumn", you can create a measure like this:

ColorMeasure =
SWITCH (
TRUE (),
MAX ( 'YourTable'[ValueColumn] ) = 1, "Green",
MAX ( 'YourTable'[ValueColumn] ) = 2, "Blue",
MAX ( 'YourTable'[ValueColumn] ) = 3, "Red",
"Other"
)

 

  1. Replace 'YourTable' with the name of your table, and 'ValueColumn' with the actual name of your column.

  2. Apply Conditional Formatting: Now, you can apply conditional formatting to your column header based on the measure you created.

    • Click on the column header in your table visualization.
    • Go to the "Format" pane on the right.
    • Under "Conditional formatting", select "Text color" (or any other formatting option you prefer).
    • Choose "Field value" as the formatting based on the measure you created (ColorMeasure).
    • Define the colors for each condition (e.g., Green for value 1, Blue for value 2, Red for value 3).
  3. Refresh Data: Whenever your data in Excel is updated, refresh your Power BI dataset. Power BI will automatically reflect the changes in your visualizations, including the conditional formatting.

This approach allows you to dynamically apply conditional formatting to the column header in Power BI based on the values from Excel.

 
 
 
 

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.

 

In case there is still a problem, please feel free and explain your issue in detail, It will be my pleasure to assist you in any way I can.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors