Forum Discussion

AzarShaik-8386's avatar
AzarShaik-8386
Frequent Visitor
1 year ago
Solved

Power BI conditional formatting highlight specific text in each row for table visual

Hi Power BI Community,

I have a table visual in Power BI where one of the columns contains text data. I would like to highlight specific text in different rows, where the text to be highlighted changes per row. For example:

  • In Row 1, I want to highlight the word "urgent."
  • In Row 2, I want to highlight the word "critical."
  • In Row 3, I want to highlight the word "info," and so on.

I understand that Power BI’s native conditional formatting allows for entire cells or rows to be highlighted, but I am looking for a way to apply different text-based rules to highlight specific values in different rows of the table visual. Is there a method or workaround that would allow me to achieve this level of granularity?

Here’s what I’ve tried so far:

  • I’ve created a DAX measure using SWITCH(TRUE()) to check for specific text values in each row and apply conditional formatting based on those values.
  • However, this ends up highlighting the entire row or cell instead of just the specific text.

Is there a way to highlight only the relevant text within a cell or apply cell-level conditional formatting differently per row?

Thanks for any guidance or suggestions!

  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi AzarShaik-8386 ,

    I create a simple table as you mentioned.

    Then I create a calculated column and here is the DAX code.

    HighlightedText = 
    SWITCH(
        TRUE(),
        'Table'[RowID] = 1, SUBSTITUTE('Table'[TextColumn], "urgent", "<span style='background-color:yellow'>urgent</span>"),
        'Table'[RowID] = 2, SUBSTITUTE('Table'[TextColumn], "critical", "<span style='background-color:red'>critical</span>"),
        'Table'[RowID] = 3, SUBSTITUTE('Table'[TextColumn], "info", "<span style='background-color:green'>info</span>"),
        'Table'[TextColumn]
    )

    So I think you can use the visual named HTML Content.

     

     

     

    Best Regards

    Yilong Zhou

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

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi AzarShaik-8386 ,

    I create a simple table as you mentioned.

    Then I create a calculated column and here is the DAX code.

    HighlightedText = 
    SWITCH(
        TRUE(),
        'Table'[RowID] = 1, SUBSTITUTE('Table'[TextColumn], "urgent", "<span style='background-color:yellow'>urgent</span>"),
        'Table'[RowID] = 2, SUBSTITUTE('Table'[TextColumn], "critical", "<span style='background-color:red'>critical</span>"),
        'Table'[RowID] = 3, SUBSTITUTE('Table'[TextColumn], "info", "<span style='background-color:green'>info</span>"),
        'Table'[TextColumn]
    )

    So I think you can use the visual named HTML Content.

     

     

     

    Best Regards

    Yilong Zhou

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