Can a chart range have an IF statement?

birdieman

Well-known Member
Joined
Jan 13, 2016
Messages
551
In excel, I would like to make a chart whose range depends on an if statement. So, can you put an if statement in the "series values" when making a chart?? For example, if cell B6 is 50 or less, make a chart whose series values is C6:C30, otherwise the series values is C6:C20?


I tried a formula in the "series values" box, but kept getting an "invalid function" and I do not know if you cannot do what I want, or if I have a bad syntax formula.
thanks for looking
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
will explore that option, but I would still need an if statement, and I do not know if an "if" statement is allowed when specifying a range -- whether the range is named or not?????

thanks for responding
 
Upvote 0
Code:
=offset('annual recap (2)' !$K$6,,,If('Annual recap (2)'!$b$6<50,70,40))

The above line, which I put in Series values, gives me an "invalid function" error

the sheet name where the data is located (not the sheet were the chart resides) is Annual Recap; the data to chart begins in K6, and I want to plot the first 70 values of 80 total values (in column K) if B6 < 50 and plot 40 values of 80 total values in same column if not.

Did I do something wrong
 
Last edited:
Upvote 0
I copied Sheet6 without renaming so Excel calls it Sheet6(2). Don't add a (2) if it's not part of the name.
 
Last edited:
Upvote 0
You can create a new Named Range (Formulas > Name Manager > New), give it a name and add the following formula:

=IF('Annual Recap'!$B$6<50,'Annual Recap'!$K$4:$K$45,'Annual Recap'!$K$6:$K$85)

Then create your chart, right click on it > Select Data, Add Series, name it as you wish and in the Series values delete everything and add

='Annual Recap'!thenameofyourrange

I hope this helps.

Cheers,
Catalin
 
Upvote 0

Forum statistics

Threads
1,222,585
Messages
6,166,920
Members
452,083
Latest member
Paul330

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top