+ Reply to Thread
Results 1 to 18 of 18

How would you set up a dynamic range based on this condition

  1. #1
    Registered User
    Join Date
    12-09-2014
    Location
    Oliver Canada
    MS-Off Ver
    2007
    Posts
    13

    How would you set up a dynamic range based on this condition

    I am trying to get my chart to update as more data is added. but I need a check to see if the cell contains a 0 or not and if it does then don't update. I want to use

    C10:INDEX(C10:C19,IFERROR(MATCH(0,C10:C19,0)-1,COUNT(C10:C19))) <- the cell range here defines the X values for both of my curves in my chart
    D10:INDEX(D10:D19,IFERROR(MATCH(0,D10:D19,0)-1,COUNT(D10:D19))) <- the cell range here defines the Y values for curve 1
    E10:INDEX(E10:E19,IFERROR(MATCH(0,E10:E19,0)-1,COUNT(E10:E19))) <- the cell range here defines the Y values for curve 2 that is on the same chart

    XValues, Y Values1, Y Values2
    30, 176.7, 176.7,
    60, 297.9, 121.2,
    90, 468.3, 170.4,
    120, 643.9, 175.6,
    150, 808.6, 164.7,
    180, 991.9, 183.3,
    210, 1111, 119.1,
    240, 1222, 111,
    270, 1342, 120,
    0, 0, 0,
    0, 0, 0,
    0, 0, 0,
    0, 0, 0,
    0, 0, 0,
    0, 0, 0,
    ...etc etc where these 0's are updated by a different function based on conditions. I need my chart to reflect the changes so if a 0 is changed to a neg or positive value then the graph shows the change otherwise it doesn't.

    how can you achieve this using a dynamic range

  2. #2
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,951

    Re: How would you set up a dynamic range based on this condition

    I may have missed the point here, but the below three formulas should take care of dynamic named ranges.
    Presumably if column C is not zero then you would want to plot D & E on the chart?

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    BSB
    Last edited by BadlySpelledBuoy; 12-10-2014 at 04:42 PM.

  3. #3
    Registered User
    Join Date
    12-09-2014
    Location
    Oliver Canada
    MS-Off Ver
    2007
    Posts
    13

    Re: How would you set up a dynamic range based on this condition

    Basically I want two graphs on my chart. graph one uses columns C and D and graph 2 uses C and E. Both Graphs contain a bunch of cells thata re non zero values and a bunch for cells that are 0.I use a conditional formula to change the zeros to numbers based on other stuff that happens. What I want to accomplish is for the graphs to add the non zero datapoints and display them and not display the zero data points. so in the data I listed above I want to display the data above (and including) 270, 1342, 120, but no data below it because it is all zero. If the next line changes from all 0 to all numbers I want the chart to alter its range and display those points also.

  4. #4
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,951

    Re: How would you set up a dynamic range based on this condition

    Have you tried the formulas I provided to see if they do what you need?

    BSB.

  5. #5
    Registered User
    Join Date
    12-09-2014
    Location
    Oliver Canada
    MS-Off Ver
    2007
    Posts
    13

    Re: How would you set up a dynamic range based on this condition

    I cant get them to work

  6. #6
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,951

    Re: How would you set up a dynamic range based on this condition

    Could you post a sample workbook?

    BSB.

  7. #7
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,453

    Re: How would you set up a dynamic range based on this condition

    As I asked in your other thread on the same topic, is there a specific step or part of creating a dynamic named range that you are having trouble implementing? It might be easier for us to help you if we had a better idea what part you "can't get to work".
    Last edited by MrShorty; 12-10-2014 at 04:02 PM.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  8. #8
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: How would you set up a dynamic range based on this condition

    I suggest that you have your data in a table and don't enter values until you have them. With data in a table, the chart will expand with the added data. I tricked the chart into accepting the X values as X axis values by first entering some dates, created the chart then entered the proper values for the X axis (changing the formatting of the data of course).
    Attached Files Attached Files
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

  9. #9
    Registered User
    Join Date
    12-09-2014
    Location
    Oliver Canada
    MS-Off Ver
    2007
    Posts
    13

    Re: How would you set up a dynamic range based on this condition

    This is the file I am working on, as you can see I want the chart to display the fields with non zero values only. And if the cells are zero I don't want them to be displayed on the chart. To do this I need the chart to only expand its range if the cells are non zero otherwise keep the range the same
    Attached Files Attached Files
    Last edited by unnobtanium; 12-10-2014 at 04:31 PM.

  10. #10
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,951

    Re: How would you set up a dynamic range based on this condition

    Have a look at the attached. Is this the sort of thing you mean?

    BSB
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    12-09-2014
    Location
    Oliver Canada
    MS-Off Ver
    2007
    Posts
    13

    Re: How would you set up a dynamic range based on this condition

    Yes Exactly, Thank you

  12. #12
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,453

    Re: How would you set up a dynamic range based on this condition

    unnobtanium: If you compare your spreadsheet with BSB's spreadsheet, I think you will find that, where you defined your names with relative references, BSB defined names using absolute references. While I'm sure there are cases you would want to define a name with relative references, most cases (including this one) will want to have names defined using absolute references. You might try going back to your spreadsheet and defining your names with absolute references to see if you get the same result as BSB.

  13. #13
    Registered User
    Join Date
    12-09-2014
    Location
    Oliver Canada
    MS-Off Ver
    2007
    Posts
    13

    Re: How would you set up a dynamic range based on this condition

    I figured it out thanks everyone for the help

  14. #14
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,951

    Re: How would you set up a dynamic range based on this condition

    Glad you got what you needed.

    Don't forget to mark the thread as SOLVED if you're happy you have your solution.

    BSB.

  15. #15
    Registered User
    Join Date
    12-09-2014
    Location
    Oliver Canada
    MS-Off Ver
    2007
    Posts
    13

    Re: How would you set up a dynamic range based on this condition

    I do have a question In my current setup the point 0,0 gets included and I don't want this to happen. Why is it happening here is my excel file
    Attached Files Attached Files

  16. #16
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,453

    Re: How would you set up a dynamic range based on this condition

    I don't have a good answer, yet. The 0,0 point in the chart suggests that your named ranges are returning at least one of the 0,0 points. My debugging strategy so far:

    1) Select G10:G24, insert named range =filtertime and ctrl-shift-enter. This enters the resulting array that the named range is supposed to return. This allows to inspect the named range and see if it is returning what is expected. I note that it is returning the 5 non-zero values and 5 zeroes before returning N/A (indicating end of range). It would seem that something is not quite right.
    2) Inspecting the name definition, I ask myself what the countif is returning. So, I enter =COUNTIF(C10:c24,"<>0") in a cell. It returns 10 (not 5 like expected). It looks like something is wrong with the countif part of the function. I have to admit that I don't know what is wrong with it.
    3) Test each entry in C10:C24 with something like =c10<>0. TRUE is returned for the non-zero values, and FALSE is returned for the zero values.
    4) Since all of the non-zero values are >0 (none are less than zero), I edit the countif function accordingly =COUNTIF(c10:c24,">0") returns 5. Out of curiosity, I note that "<0" returns 0 and "=0" returns 5 and "><0" returns 0. For some reason, not equal to <> 0 seems to count those cells with 0 in them. Not sure what is going on here.

    Short term solution: If you know that your values will always be greater than 0, drop the not equal to operator and use greater than.
    Long term solution: Become more familiar with how Excel handles the <> operator in the countif() function to better understand why it is counting the zeroes.

  17. #17
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,453

    Re: How would you set up a dynamic range based on this condition

    Additional observation. In sheet2, I put =sheet1!C10 and copied down to C24 (deleted the "pass" from the merged C22 cell). In sheet2, =countif(C10:C24,"<>0") returns 5. The error in the countif() function seems to be limited to your sheet1. Still not sure why. Probably going to take a mind far superior to mine to understand this behavior.

  18. #18
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,453

    Re: How would you set up a dynamic range based on this condition

    Next observation: Your named range refers to rows 10:24, but only rows 10:19 are actually used. =countif(c10:c19,"<>0") returns 5, countif(c20:c24,"<>0") also returns 5. For some reason, the countif function is saying that blank/empty does not equal 0. Is there a reason to include rows 20 to 24, when the structure of the table obviously suggests that the table stops at row 19?

+ 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. Replies: 3
    Last Post: 03-22-2014, 01:54 PM
  2. [SOLVED] Copy a dynamic range based on condition in new worksheet
    By StephenVerheul in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-10-2013, 06:59 AM
  3. [SOLVED] dynamic range specification (based on column header) in sumproduct multiple condition
    By anand_erin in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 10-28-2012, 10:16 PM
  4. Dynamic row selection based on condition
    By Hornet222 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-03-2011, 04:25 PM
  5. Replies: 3
    Last Post: 08-19-2006, 08:15 AM

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