Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
bassmaninaus_PB
Frequent Visitor

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..

Max Bar Highlighted.png

Multiple or all dates selected..

Max Bar Not Highlighted.png

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
)

 

1 ACCEPTED SOLUTION

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

vcgaomsft_0-1656576191352.png

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

View solution in original post

6 REPLIES 6
v-cgao-msft
Community Support
Community Support

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"
)

vcgaomsft_0-1655882491379.png

vcgaomsft_1-1655882518079.png

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

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.

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

vcgaomsft_0-1656576191352.png

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

Magic, exactly what I wanted, thanks Gao!!

Whitewater100
Solution Sage
Solution Sage

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:
Whitewater100_0-1655428362845.png

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!
Whitewater100_1-1655428748501.png

 

Great, thanks Whitewater100, will give it a go!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors