Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

Color for Max on Bar Chart formula not working

I'm new to power bi and I'm trying to color the min and max column in my bar chart differently from the rest of the bar chart columns.  I've looked at different options online.  None of the formulas error out, they just don't work.  This is one of the formulas I've tried.  But none of the formulas I've tried have worked 

Max_Min Color =
var v1=
maxx(ALLSELECTED(point_balance_by_member[point_bin]),calculate(COUNT(point_balance_by_member[user_id])))
var v2=
minx(ALLSELECTED(point_balance_by_member[point_bin]),calculate(COUNT(point_balance_by_member[user_id])))
return
if(count(point_balance_by_member[user_id])=v1,"Dark Blue",if(count(point_balance_by_member[user_id])=v2,"Light Blue","Green"))

 

 

8 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you pankajnamekar25 it worked.  Though I don't understand why, since the gray is >= and <=, which is inclusive of 0 and 100, which would overlap with the next two rules, and none of the bars technically are 100% or 0%.  I'll have to do more research.  Thank you again!!!

  • v-venuppu's avatar
    v-venuppu
    Icon for Community Support rankCommunity Support

    Hi Anonymous ,

    As this thread is already solved, please create a new thread in the forum community.We are happy to help.

    Thank you.

  • v-venuppu's avatar
    v-venuppu
    Icon for Community Support rankCommunity Support

    Hi Anonymous ,

    Thank you for reaching out to Microsoft Fabric Community.

    Thank you Ashish_Excel pankajnamekar25 for the prompt response.

    I have created sample pbix file by using sample data to replicate the scenario.

    You can find the attached .pbix file for your reference.

    After creating chart , Apply Conditional Formatting

    Select the chart.

    In the Visualizations > Format pane, expand Columns > Colors.

    Set:

    Format by: Field value

    Based on field: BarColor measure

     

    If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it! 

    Thank you.

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Regretfully this had the same effect as my formula, i.e. it formatted all bars as though they were the max.  I thought possibly it was because I had the count of user id displayed "show values as percent of total" but when I returned to "no calculation" (just showing the counts and not the percent) the same result.  However pankajnamekar25 response did work.  I'm sure it's something I'm doing, so hopefully I'll get better at this.  Thank you.

  • Anonymous's avatar
    Anonymous
    Not applicable

    I was unable to understand why this works.  I now now have a parameter instead of a single measure that I am trying to format similarly.  Is there a way to format conditionally similarly when the measure used in the column chart is a parameter choice with a slider.  Maybe I should start another post (?)

    • Ashish_Mathur's avatar
      Ashish_Mathur
      Icon for Super User rankSuper User

      Hi,

      Share the download link of the PBI file.  Explain (in a text box) the expected result there.