Forum Discussion

Creative_tree88's avatar
1 year ago
Solved

X Axis Text Formatting to colour

Hi - I have a chart which has the usual black X axis value formatting applied.  However, I'd like to highlight our specific organisation "Liverpool" on the X axis, so the user can easily identify "Liverpool" i.e. I need to make it stand out amongst the other values.

 

Is there a way to do this?

 

The table which holds this name field is called "Provider Name" and field is called "Short text".  Value = "Liverpool"

 

Many thanks as always!

  • Anonymous's avatar
    Anonymous
    1 year ago

    Thanks for DataNinja777's concern about this issue.

     

    Hi, Creative_tree88 

    I am glad to help you.

     

    Currently, there is no way to modify the color of the Text of the X-axis directly through conditional formatting in Power BI.


    If you simply want users to be able to easily recognize Liverpool, perhaps you can try the following:
    You can choose to use Table visual to distinguish Liverpool from other Provider Names by changing the color of the Text:
    Create a Measure:

    Color Measure = IF(SELECTEDVALUE('Table'[Provider Name]) = "Liverpool", "Red", "Black")

     

     

     

     


    Or you can distinguish Liverpool from other Provider Names by having different colored bars:
    Create a Measure:

    Color Measure2 = IF(SELECTEDVALUE('Table'[Provider Name]) = "Liverpool", "Red", "Blue")

     

     

     

    I have attached the pbix file for this simple example below, I hope it helps.

     

     

    I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
    Best Regards,
    Fen Ling,
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

3 Replies

  • Hi Creative_tree88 ,

     

    To highlight "Liverpool" on the X-axis in your Power BI chart, you can achieve this by creating a custom DAX measure that conditionally formats the text color based on the value in the "Provider Name" field. Since Power BI does not support direct conditional formatting of X-axis labels, this workaround involves using a measure to dynamically change the color of the text based on whether the value equals "Liverpool."

    Start by creating a DAX measure to return a different color code when the Provider Name is "Liverpool." You can use the following DAX code:

    HighlightProvider = 
    IF(
        SELECTEDVALUE('Provider Name'[Short text]) = "Liverpool",
        "#FF0000",  // Red color for Liverpool
        "#000000"   // Black color for all other values
    )
    

    Once you've created this measure, go to the Format pane of your visual, select "Data colors," and apply conditional formatting using the HighlightProvider measure. This will ensure that "Liverpool" stands out in a different color on the X-axis.

    Alternatively, if you prefer to make "Liverpool" stand out by modifying the text label itself, you can create another measure to add symbols or text around "Liverpool" to differentiate it from other values. Here's an example of a custom label measure:

    CustomLabel = 
    IF(
        SELECTEDVALUE('Provider Name'[Short text]) = "Liverpool",
        "Liverpool (Highlighted)",  
        SELECTEDVALUE('Provider Name'[Short text])
    )
    

    Replace the original "Provider Name" field in your chart with this CustomLabel measure. This will add visual emphasis to "Liverpool" directly in the chart labels. While this doesn't change the color of the X-axis label text itself, it draws attention to the specific value you want to highlight.

     

    Best regards,

  • DataNinja777 Many thanks.  Can you perhaps demo this for me, please?  I created the measure, but the X axis text is all still black.  Liverpool is not shown in red.  Many thanks.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Thanks for DataNinja777's concern about this issue.

     

    Hi, Creative_tree88 

    I am glad to help you.

     

    Currently, there is no way to modify the color of the Text of the X-axis directly through conditional formatting in Power BI.


    If you simply want users to be able to easily recognize Liverpool, perhaps you can try the following:
    You can choose to use Table visual to distinguish Liverpool from other Provider Names by changing the color of the Text:
    Create a Measure:

    Color Measure = IF(SELECTEDVALUE('Table'[Provider Name]) = "Liverpool", "Red", "Black")

     

     

     

     


    Or you can distinguish Liverpool from other Provider Names by having different colored bars:
    Create a Measure:

    Color Measure2 = IF(SELECTEDVALUE('Table'[Provider Name]) = "Liverpool", "Red", "Blue")

     

     

     

    I have attached the pbix file for this simple example below, I hope it helps.

     

     

    I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
    Best Regards,
    Fen Ling,
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.