Forum Discussion

bassmaninaus_PB's avatar
bassmaninaus_PB
Frequent Visitor
4 years ago
Solved

Highlighting the max value in bar chart issue

Hi,

I'm trying to highlight the max value in my bar chart, I have it partially working however need help to finalise.

As you can see this works with selecting an individual date, however if I select a range of dates or all dates the highlighted bar reverts.

One date selected..

Multiple or all dates selected..

The DAX I'm using for the highlight is as follows, any help to get this working, appreciated!

Max Interval = 
VAR MaxInterval = MAXX(ALLSELECTED(Interval),[Avg Calls per Interval])
Return
IF(
   [Avg Calls per Interval] = MaxInterval,
    1,
    0
)

 

  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi bassmaninaus_PB ,

     

    Please try this.

    Max Interval = 
    VAR _max =
    CALCULATE(
        MAXX (
           SUMMARIZE('Table','Table'[Interval],"Avg",[Avg Calls per Interval]),
            [Avg]
        ),
        ALLSELECTED()
    )
    VAR _colour =
        IF ( [Avg Calls per Interval] = _max , "red" )
    RETURN
        _colour

    The PBIX file is attached for reference.

     

    Best Regards,
    Gao

    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    How to get your questions answered quickly -- How to provide sample data

6 Replies

  • Hi:

    You can create a slicer where you choose how long the period under scrutiny will be

    New Table :

    Period = GENERATESERIES(1, 180, 3)
    It will look like this:

    Then you just sub in your table and measure names instead of mine: Your fact table with a date field replaces my 

     Retailer_Sales[Ship_Date]. And you use your [Avg Calls per Interval] measure where I used [Last x Days Sales].

     

    It's important to have date table, marked as date table and formed relationship with your interval table. The result can look like(see last image).

     

    Max Last x Days =
    var periodselected = Period[Period Value]
    var maxsales =
    MAXX(ALLSELECTED(Retailer_Sales[Ship_Date]),
    [Last x Days Sales])
    var maxdate =
    CALCULATE(MAX(Retailer_Sales[Ship_Date]),
    FILTER(ALLSELECTED(Retailer_Sales[Ship_Date]),
    [Last x Days Sales] = maxsales))
    var final =
    CALCULATE(SUM(Retailer_Sales[Qty_Sold]),
    FILTER(Retailer_Sales,
    Retailer_Sales[Ship_Date] > maxdate - periodselected &&
    Retailer_Sales[Ship_Date] <= maxdate))
    return
    final
     I hope this helps! Below shows a mi value which just used min vs max in the same forumla. Good luck!

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi bassmaninaus_PB ,

     

    Please create this measure and set it to the bar chart conditional format.

    Max Interval = 
    VAR MaxInterval = MAXX(ALLSELECTED(Interval),[Avg Calls per Interval])
    Return
    IF(
       [Avg Calls per Interval] = MaxInterval,
        "Red"
    )

    Attached PBIX file for reference.

     

    Best Regards,
    Gao

    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    How to get your questions answered quickly -- How to provide sample data

    • bassmaninaus_PB's avatar
      bassmaninaus_PB
      Frequent Visitor

      Thanks Gao, I can't quite get it to work with the interval as the x axis. Selecting one date ie 6th June by itself works, not when both dates are selected in a slicer. Very small sample data attached. 

      DateCallsInterval
      Mon 6 Jun 221.4089787197:30:00 AM
      Mon 6 Jun 221.8673211947:45:00 AM
      Mon 6 Jun 221.7315160168:00:00 AM
      Mon 6 Jun 221.8503455468:15:00 AM
      Mon 6 Jun 222.800981798:30:00 AM
      Mon 6 Jun 223.412105098:45:00 AM
      Mon 6 Jun 223.5818615629:00:00 AM
      Mon 6 Jun 224.753181229:15:00 AM
      Mon 6 Jun 224.6852786319:30:00 AM
      Mon 6 Jun 227.1637231249:45:00 AM
      Mon 6 Jun 228.02948113210:00:00 AM
      Mon 6 Jun 229.60821632310:15:00 AM
      Tue 7 Jun 221.2792343137:30:00 AM
      Tue 7 Jun 221.6953707777:45:00 AM
      Tue 7 Jun 221.5720710848:00:00 AM
      Tue 7 Jun 221.6799583158:15:00 AM
      Tue 7 Jun 222.5430561658:30:00 AM
      Tue 7 Jun 223.0979047838:45:00 AM
      Tue 7 Jun 223.2520293999:00:00 AM
      Tue 7 Jun 224.315489259:15:00 AM
      Tue 7 Jun 224.2538394039:30:00 AM
      Tue 7 Jun 226.5040587989:45:00 AM
      Tue 7 Jun 227.2900943410:00:00 AM
      Tue 7 Jun 228.72345326910:15:00 AM

      Any help appreciated.

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi bassmaninaus_PB ,

         

        Please try this.

        Max Interval = 
        VAR _max =
        CALCULATE(
            MAXX (
               SUMMARIZE('Table','Table'[Interval],"Avg",[Avg Calls per Interval]),
                [Avg]
            ),
            ALLSELECTED()
        )
        VAR _colour =
            IF ( [Avg Calls per Interval] = _max , "red" )
        RETURN
            _colour

        The PBIX file is attached for reference.

         

        Best Regards,
        Gao

        Community Support Team

         

        If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

        How to get your questions answered quickly -- How to provide sample data