Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

How do you conditional colour the maximum value in Bar chart?

 

Hello everyone.

How would I ensure the maximum value (in this case March) be coloured differently to the rest of the values? Thanks

  • Hello Anonymous

     

    you need to create two measures:

     

    MaxValue = 
    VAR _MAXValue = MAXX( ALL( 'Date'[Month], 'Date'[Month Number] ), [Total Sales] )
    RETURN
    IF( [Total Sales] = _MAXValue, _MAXValue, BLANK() )

    and

     

    SalesTotal = 
    VAR _MAXValue = MAXX( ALL( 'Date'[Month], 'Date'[Month Number] ), [Total Sales] )
    VAR _TotSales = [Total Sales]
    RETURN
    IF( _TotSales = _MAXValue, BLANK(), _TotSales )

    where  [Total Sales] is this measure (this depends on your model and is the 1 your currently using in your chart above):

     

    Total Sales = SUMX( Sales, Sales[Net Price] * Sales[Quantity] )

    then add STACKED bar chart with months on the X axis and the two measures. Also for temporal data, i advise you to place it horizontally and not vertically

     

     

     

2 Replies

  • Hello Anonymous

     

    you need to create two measures:

     

    MaxValue = 
    VAR _MAXValue = MAXX( ALL( 'Date'[Month], 'Date'[Month Number] ), [Total Sales] )
    RETURN
    IF( [Total Sales] = _MAXValue, _MAXValue, BLANK() )

    and

     

    SalesTotal = 
    VAR _MAXValue = MAXX( ALL( 'Date'[Month], 'Date'[Month Number] ), [Total Sales] )
    VAR _TotSales = [Total Sales]
    RETURN
    IF( _TotSales = _MAXValue, BLANK(), _TotSales )

    where  [Total Sales] is this measure (this depends on your model and is the 1 your currently using in your chart above):

     

    Total Sales = SUMX( Sales, Sales[Net Price] * Sales[Quantity] )

    then add STACKED bar chart with months on the X axis and the two measures. Also for temporal data, i advise you to place it horizontally and not vertically

     

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

       

      Worked great thanks