+ Reply to Thread
Results 1 to 9 of 9

Highlight max positive and negative on chart.

  1. #1
    Registered User
    Join Date
    10-12-2023
    Location
    USA
    MS-Off Ver
    2021
    Posts
    7

    Highlight max positive and negative on chart.

    Hi.

    I have a chart that updates automatically. What I want to do is to highlight max positive and negative values with lines that extend all the way to both sides like #1 and #2 in the image.
    I've looked allover and found only one video, but can't replicate the results. I'm using excel 2016.

    Thank you.
    Attached Images Attached Images

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,947

    Re: Highlight max positive and negative on chart.

    The general approach is to add two more series to your chart, tied to an alternate axis. The method depends on your data structure - can you share a sanitized example workbook with your current chart?
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Highlight max positive and negative on chart.

    What kind of strategies have you tried and rejected? I worry about repeating ideas that you already don't want to use.

    My first thought, because of its simplicity, would be to simply add two additional data series to the clustered bar chart. One data series based on a column with a formula like =IF(OR(MAX(values)=thisvalue,MIN(values)=thisvalue),maxvalue,0) and the other data series based on a column with a formula like =IF(OR(MAX(values)=thisvalue,MIN(values)=thisvalue),minvalue,0).

    I would start with that, see what you like and don't like about that, and then we can move forward from there.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  4. #4
    Registered User
    Join Date
    10-12-2023
    Location
    USA
    MS-Off Ver
    2021
    Posts
    7

    Re: Highlight max positive and negative on chart.

    Here's the workbook.

    One data series based on a column with a formula like =IF(OR(MAX(values)=thisvalue,MIN(values)=thisvalue),maxvalue,0) and the other data series based on a column with a formula like =IF(OR(MAX(values)=thisvalue,MIN(values)=thisvalue),minvalue,0).
    I've tried similar method, but for some reason I can't get the max value to display at the correct price, 4280 in this case. It always ends up all the way at the bottom.
    Attached Files Attached Files
    Last edited by Spartan79; 10-13-2023 at 01:25 PM.

  5. #5
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Highlight max positive and negative on chart.

    You've done something with your uploaded sample file so that Excel will not allow me to even select or investigate what is in the chart.

    If I trust LO Calc, I can open the file in LO Calc and examine the chart. First I note that the chart is using D3:D36 for the category axis labels for all data series. It appears that you have three data series for that category axis. The main data series using B3:B36 for the values, a second data series using only G3:G4 for the values (which, because there are only two cells in the range, will be charted against the first two categories on the category axis, which is why they are showing up at the bottom of the chart), and a third data series using only H3:H4 for the values (again, plotted against the first two categories).

    If it would let me, I would make the following edits to your file (after checking my second thought below):

    1) I don't know what column H is trying to do, so clear H and remove the Series 2 from the chart.
    2) Edit Series 3 in the chart so that it points to G3:G36, like the main data series.
    3) Enter a formula like I recommended in G3 =IF(OR(MAX($B$3:$B$36)=B3,MIN($B$3:$B$36)=B3),B3,0). Copy/paste/fill down to G36.

    That should put gray, second data series, max/min bars next to the blue, first data series, max/min bars.

    That's probably not the final solution. Now that we have the max/min bars in the appropriate position along the category axis, what would you like to do next?

    Another thing I notice, you appear to be trying to set up data for a bar + XY scatter combination chart approach. If that is correct, then the edits I would make to your file are:

    1) Remove series 2 from the chart.
    2) Select series 3 and change the chart type to XY scatter (line without marker). If your copy of Excel doesn't automatically move this series to the secondary axis system and show both horizontal and vertical secondary axes, add both secondary axes to the chart.
    3) By trial and error, find a combination of secondary vertical axis min/max and value/formula in H3:H4 that will position the XY scatter series at the correct vertical position.
    4) Format the secondary horizontal axis to have the desired limits, if the default Auto setting is inappropriate.

    Either approach can work. Try them and see what direction you want to go.

  6. #6
    Registered User
    Join Date
    10-12-2023
    Location
    USA
    MS-Off Ver
    2021
    Posts
    7

    Re: Highlight max positive and negative on chart.

    I uploaded the workbook again, hopefully this one is fine. I will try your suggestion when I get home.
    In H I get min and max of B, and G shows me what "strike" the max of B is at, in this case 4280.

    Thank you.
    Attached Files Attached Files
    Last edited by Spartan79; 10-13-2023 at 01:35 PM.

  7. #7
    Registered User
    Join Date
    10-12-2023
    Location
    USA
    MS-Off Ver
    2021
    Posts
    7

    Re: Highlight max positive and negative on chart.

    That's perfect, exactly what I was looking for.

    Thank you MrShorty.

    One more thing. Is there a way to extend the same series to both sides of the y axis? So that one series displays on positive and negative.
    The only work around I've found is to plot another series with opposite values. But that doesn't look nice as the lines are not aligned, not to mention a ton of series.

    I drew a black line on the chart at 4300 to show what I would like to achieve.
    Attached Files Attached Files
    Last edited by Spartan79; 10-14-2023 at 09:13 PM.

  8. #8
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Highlight max positive and negative on chart.

    That sounds about right for a clustered bar chart like you are using here.

    As a bar chart, my first thought would be use a stacked bar chart with a "sparse" data layout in the spreadsheet to make a "clustered and stacked" bar chart. See tutorial here https://peltiertech.com/charts-for-excel/cluster-stack/ . Note that most of the work is arranging the data in the spreadsheet, so a lot depends on how readily you can rearrange the data (or a copy of the data).

    My second thought would be to return the idea of a bar + scatter combo chart. The spreadsheet work will be easier, but building the chart will be the difficult part. Here's a tutorial for making a generic bar + scatter combination chart that should be readily adaptable to the scenario where you want to add a horizontal line to bar chart: https://peltiertech.com/bar-line-xy-...hart-in-excel/

    Look over those two tutorials, decide which approach you want to try, then let us know where you get stuck following the tutorials.

  9. #9
    Registered User
    Join Date
    10-12-2023
    Location
    USA
    MS-Off Ver
    2021
    Posts
    7

    Re: Highlight max positive and negative on chart.

    Sorry for the late replay, was a bit busy.

    Tried to play around with both ideas, but can't achieve what I want. But what I have right now works.

    Again, thank you very much.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Highlight identical values in range (positive and negative)
    By lofgren in forum Excel General
    Replies: 2
    Last Post: 03-30-2022, 05:47 AM
  2. [SOLVED] Highlight row based on two cells with positive/negative figures
    By ~TaC~ in forum Excel Programming / VBA / Macros
    Replies: 31
    Last Post: 01-28-2021, 03:08 PM
  3. Replies: 7
    Last Post: 06-18-2015, 02:23 AM
  4. Replies: 2
    Last Post: 08-04-2014, 08:57 AM
  5. Chart with 2 axes - 1 positive and 1 negative
    By liybpg in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 04-05-2013, 07:24 AM
  6. Replies: 2
    Last Post: 11-21-2012, 07:27 AM
  7. Convert negative to positive in sheet containing both positive/negative numbers
    By sa02000 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-29-2010, 07:52 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1