Excel Chart - x axis won't automatically resize when there is no data to display

%3CLINGO-SUB%20id%3D%22lingo-sub-1203774%22%20slang%3D%22en-US%22%3EExcel%20Chart%20-%20x%20axis%20won't%20automatically%20resize%20when%20there%20is%20no%20data%20to%20display%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1203774%22%20slang%3D%22en-US%22%3E%3CDIV%20class%3D%22p-pageWrapper%22%3E%3CDIV%20class%3D%22p-body%22%3E%3CDIV%20class%3D%22p-body-inner%22%3E%3CDIV%20class%3D%22p-body-main%20%20%22%3E%3CDIV%20class%3D%22p-body-content%22%3E%3CDIV%20class%3D%22p-body-pageContent%22%3E%3CDIV%20class%3D%22block%20block--messages%22%3E%3CDIV%20class%3D%22block-container%20lbContainer%22%3E%3CDIV%20class%3D%22block-body%20js-replyNewMessageContainer%22%3E%3CDIV%20class%3D%22message-inner%22%3E%3CDIV%20class%3D%22message-cell%20message-cell--main%22%3E%3CDIV%20class%3D%22message-main%20js-quickEditTarget%22%3E%3CDIV%20class%3D%22message-content%20js-messageContent%22%3E%3CDIV%20class%3D%22message-userContent%20lbContainer%20js-lbContainer%20%22%3E%3CDIV%20class%3D%22bbWrapper%22%3EI'm%20charting%20very%20simple%20data%20from%20a%20set%20range%20-%20charting%20as%20a%20bar%20graph.%20This%20range%20will%20include%20blank%2F%23N%2FA%20(I%20can%20adjust%20my%20formulas%20to%20whatever%20is%20needed)%20until%20new%20data%20comes%20in%20via%20formula...it's%20chronological%20so%20I%20have%20room%20for%20future%20dates'%20data.%3CBR%20%2F%3E%3CBR%20%2F%3EI'm%20not%20able%20to%20create%20a%20chart%20that%20will%20ignore%20the%20currently%20empty%20future%20data.%20Instead%20it%20plots%20along%20the%20x%20axis%20leaving%20me%20with%20a%20condensed%20graph%20unnecessarily.%20Hoping%20this%20makes%20sense!%20I've%20tried%20things%20and%20have%20had%20no%20success.%3CDIV%20class%3D%22lbContainer%20lbContainer--inline%22%3E%3CDIV%20class%3D%22lbContainer-zoomer%20js-lbImage-attachment7976%22%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1203774%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ECharting%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1203993%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20Chart%20-%20x%20axis%20won't%20automatically%20resize%20when%20there%20is%20no%20data%20to%20display%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1203993%22%20slang%3D%22en-US%22%3ESince%20your%20range%20will%20include%20%23N%2FA!..%20I%20will%20suggest%20you%20deploy%20IFNA%20function%20to%20handle%20the%20error%20so%20that%20it%20doesn't%20impact%20your%20chart%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1204239%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20Chart%20-%20x%20axis%20won't%20automatically%20resize%20when%20there%20is%20no%20data%20to%20display%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1204239%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F421698%22%20target%3D%22_blank%22%3E%40Abiola1%3C%2FA%3E%26nbsp%3BThanks%20for%20the%20reply.%20I%20can%20easily%20change%20the%20data%20to%20appearing%20blank%20rather%20than%20%23N%2FA.%20It's%20the%20graphing%20that%20I%20can't%20work%20out%20what%20to%20do.%20Would%20love%20some%20advice.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1205453%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20Chart%20-%20x%20axis%20won't%20automatically%20resize%20when%20there%20is%20no%20data%20to%20display%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1205453%22%20slang%3D%22en-US%22%3E%3CP%3EIs%20there%20someone%20that%20can%20show%20me%20how%20to%20do%20this%3F%20I'm%20having%20no%20success%20working%20out%20how%20to%20automatically%20ignore%20for%20this%20graphing.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1205464%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20Chart%20-%20x%20axis%20won't%20automatically%20resize%20when%20there%20is%20no%20data%20to%20display%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1205464%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F571942%22%20target%3D%22_blank%22%3E%40jmant37%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20may%20use%20dynamic%20ranges%20both%20for%20X%20and%20Y%20values%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20678px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F174648iE07B0D75BFACBA68%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3Ewith%20OFFSET%20or%20INDEX%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%3DOFFSET(Sheet1!%24A%241%2C0%2C0%2CCOUNTA(Sheet1!%24A%3A%24A)-COUNTIF(Sheet1!%24A%3A%24A%2CNA()))%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3Eor%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%3DSheet1!%24B%241%3AINDEX(Sheet1!%24B%3A%24B%2CCOUNTA(Sheet1!%24B%3A%24B)-COUNTIF(Sheet1!%24B%3A%24B%2CNA()))%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3Eand%20use%20them%20in%20chart%20like%20Sheet1!XRange%3B%20Sheet1!YRange%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1205509%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20Chart%20-%20x%20axis%20won't%20automatically%20resize%20when%20there%20is%20no%20data%20to%20display%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1205509%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3BThis%20was%20looking%20fantastic%20but%20I%20can't%20get%20it%20to%20work.%20No%20doubt%20this%20is%20just%20beyond%20me.%20I%20have%20plenty%20of%20other%20data%20in%20the%20columns%20so%20I%20adjusted%20your%20formulas%20to%20make%20a%20specific%20range%20(o33%3Ap48).%20I%20also%20attempted%20to%20use%20the%20Name%20Manager%20to%20name%20the%20ranges%2C%20as%20you%20did.%20Then%20I%20attempted%20to%20edit%20the%20series%20within%20'Select%20Data'.%20Where%20am%20I%20going%20wrong%3F%20It's%20just%20not%20working.%20I%20can%20see%20that%20yours%20functions%20perfectly.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20do%20apologise%2C%20but%20I%20only%20dabble%20in%20this%20stuff!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1207117%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20Chart%20-%20x%20axis%20won't%20automatically%20resize%20when%20there%20is%20no%20data%20to%20display%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1207117%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F571942%22%20target%3D%22_blank%22%3E%40jmant37%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThat's%20hard%20to%20say%20what%20exactly%20is%20wrong%20without%20seeing%20the%20file.%20You%20may%20incorrectly%20calculate%20dynamic%20range.%20You%20may%20use%20relative%20references%20in%20named%20formulas%20instead%20of%20absolute%20ones.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ECheck%20first%20how%20your%20dynamic%20range%20and%20named%20formula%20work%20within%20the%20sheet%20on%20formulas%2C%20after%20that%20apply%20to%20the%20chart.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2183990%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20Chart%20-%20x%20axis%20won't%20automatically%20resize%20when%20there%20is%20no%20data%20to%20display%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2183990%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3BI%20have%20a%20similar%20problem%2C%20with%20the%20main%20difference%20being%20that%20my%20chart%20data%20is%20in%20rows%20and%20not%20columns.%20Also%2C%20the%20chart%20data%20does%20not%20begin%20in%20the%20first%20column%2C%20but%20in%20column%20F%20and%20then%20needs%20to%20end%20at%20the%20last%20column%20which%20has%20data%20in%20it.%20Any%20suggestions%20will%20be%20welcome.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20want%20to%20plot%20row%207%20(dates)%20and%20row%2035%20(currency%20values)%20starting%20from%20column%20F%20up%20to%20the%20last%20column%20with%20data%20in%20it%20with%20the%20graph%20scaling%20automatically%20updated%20as%20the%20data%20range%20changes.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2184051%22%20slang%3D%22en-US%22%3ERe%3A%20Excel%20Chart%20-%20x%20axis%20won't%20automatically%20resize%20when%20there%20is%20no%20data%20to%20display%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2184051%22%20slang%3D%22en-US%22%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%20also%20note%20that%20the%20cells%20in%20row%207%20and%2035%20contains%20formulas%2C%20so%20COUNTA%20does%20not%20work.%3C%2FLINGO-BODY%3E
Occasional Contributor
I'm charting very simple data from a set range - charting as a bar graph. This range will include blank/#N/A (I can adjust my formulas to whatever is needed) until new data comes in via formula...it's chronological so I have room for future dates' data.

I'm not able to create a chart that will ignore the currently empty future data. Instead it plots along the x axis leaving me with a condensed graph unnecessarily. Hoping this makes sense! I've tried things and have had no success.
 
13 Replies
Since your range will include #N/A!.. I will suggest you deploy IFNA function to handle the error so that it doesn't impact your chart

@Abiola1 Thanks for the reply. I can easily change the data to appearing blank rather than #N/A. It's the graphing that I can't work out what to do. Would love some advice.

Is there someone that can show me how to do this? I'm having no success working out how to automatically ignore for this graphing.

@jmant37 

You may use dynamic ranges both for X and Y values

image.png

with OFFSET or INDEX

=OFFSET(Sheet1!$A$1,0,0,COUNTA(Sheet1!$A:$A)-COUNTIF(Sheet1!$A:$A,NA()))

or

=Sheet1!$B$1:INDEX(Sheet1!$B:$B,COUNTA(Sheet1!$B:$B)-COUNTIF(Sheet1!$B:$B,NA()))

and use them in chart like Sheet1!XRange; Sheet1!YRange

@Sergei Baklan This was looking fantastic but I can't get it to work. No doubt this is just beyond me. I have plenty of other data in the columns so I adjusted your formulas to make a specific range (o33:p48). I also attempted to use the Name Manager to name the ranges, as you did. Then I attempted to edit the series within 'Select Data'. Where am I going wrong? It's just not working. I can see that yours functions perfectly.

 

I do apologise, but I only dabble in this stuff!

@jmant37 

That's hard to say what exactly is wrong without seeing the file. You may incorrectly calculate dynamic range. You may use relative references in named formulas instead of absolute ones.

 

Check first how your dynamic range and named formula work within the sheet on formulas, after that apply to the chart.

@Sergei Baklan I have a similar problem, with the main difference being that my chart data is in rows and not columns. Also, the chart data does not begin in the first column, but in column F and then needs to end at the last column which has data in it. Any suggestions will be welcome.

 

I want to plot row 7 (dates) and row 35 (currency values) starting from column F up to the last column with data in it with the graph scaling automatically updated as the data range changes. 

@Sergei Baklan also note that the cells in row 7 and 35 contains formulas, so COUNTA does not work.

@Louwrensjfourie 

I assume you have something like this

image.png

In dates row we have formulas as

=EOMONTH(F7,1)

and in totals row formulas are

=SUM(G8:G34)

We add two named formula for the dynamic ranges

Dates:
=Sheet2!$F$7:INDEX(Sheet2!$F$7:$AA$7,COUNTA(Sheet2!$F$7:$AA$7))

Totals:
=Sheet2!$F$35:INDEX(Sheet2!$F$35:$AA$35,COUNTA(Sheet2!$F$7:$AA$7))

Use them in chart

x-axis:
='Chart Dynamic ranges NA.xlsx'!Dates

Totals data series:
='Chart Dynamic ranges NA.xlsx'!Totals

Please check in Sheet2 of the attached file. If you have another model it's better to illustrate on sample file.

@Sergei Baklan Thanks for the swift response. The problem is with this is that based on start and end dates the columns will be populated. I've updated your sheet to illustrate this point, see attached. Then the issue is that the formulas in the cells does not work with COUNTA as COUNTA does not see them as empty cells.

@Louwrensjfourie 

To ignore empty cells and cells with spaces you may use for dynamic ranges formulas

Dates:
=Sheet2!$F$7:INDEX(Sheet2!$F$7:$AE$7,SUMPRODUCT(1*(LEN( TRIM( Sheet2!$F$7:$AE$7)) >0)))

Totals:
=Sheet2!$F$35:INDEX(Sheet2!$F$35:$AE$35,SUMPRODUCT(1*(LEN( TRIM( Sheet2!$F$7:$AE$7)) >0)))

Please check attached. 

@Sergei Baklan that works perfectly. Thanks for your assistance. It is greatly appreciated.