Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Changing bar colour based on a Bar graph

Hi!

 

Is it possinle to chnage the colour of the bars in a bar chart based on a condition where keep all the bars for example blue if its before current month and red if its after current months. Say I have a chart with dates in x axis and sales amount on the y axis an I want to show all the sales until June in Blue bars and and July on wards in Red , is it possible yo do so?

 

Thanks,

 

  • Hi Anonymous , 

    As I know, if you want to use conditional  formatting on bar color, you can't  add field in Legend. You could refer to my sample for details.

    Best Regards,
    Zoe Zhi

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

9 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi,

     

    Step 1 : Create a measure with DAX as below:

    Current Month = MONTH(TODAY())

     

    Step 2 : Create a column for finding month from the date your have:

    Month of shipdate = MONTH(Orders[Ship Date].[Date])
     
    Step3 : Create another measure with DAX as below:
    Previous Or Future = IF(Orders[Month of shipdate]<[Current Month],"Previous","Future")
     
    Drop this "Previous Or Future" to Legends of your Bar chart.
     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Step 3 it does not allow me to make the meassure with that option.

      • Anonymous's avatar
        Anonymous
        Not applicable

        Sorry, Its suppose to be a New Column and not New Measure as this is categorical in nature.

         

        Hope this solves your issue.

  • dax's avatar
    dax
    Icon for Community Support rankCommunity Support

    Hi Anonymous , 

    As I know, if you want to use conditional  formatting on bar color, you can't  add field in Legend. You could refer to my sample for details.

    Best Regards,
    Zoe Zhi

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

    • Anonymous's avatar
      Anonymous
      Not applicable

      Great , can we do this same for clustured bar chart with multiple bars on it, because that is the problem I am facing now, I dont see the option for formating color when I have 2 bars(2 columns on Column value section)?

      • dax's avatar
        dax
        Icon for Community Support rankCommunity Support

        Hi Anonymous , 

        I don't see Column value in clustured bar chart, if possible, could you please inform me more detailed information(such as your simple sample data and your chart setting)?

        Best Regards,
        Zoe Zhi

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