Array formulas containing functions that take arrays as formulas

Dashnick

New Member
Joined
Sep 10, 2015
Messages
35
Is there a way to force excel to take formulas that normally input arrays and instead only take scalars?

As an example, say I have an array formula over a number of cells, but I only want to return 0 or greater in any given cell

So like

Code:
{=MAX(0,FunctionThatReturnsAnArray())}

say input over cells A2:C2. Problem is, this will take the entire array as input to the MAX() function, instead of cell by cell. This means that it returns the maximum of the array returned by FunctionThatReturnsAnArray() (and 0) as a scalar, instead of an array of values >=0.

Is there a way to force excel to take formulas that normally input arrays and instead only take scalars? Does this make sense?
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
It would be helpful if you'd provide some sample data and an indication of what you want done with it.

You can provide sample data by following the link in my signature below.
 
Upvote 0
Thanks DRSteele.. Below is a simple example. Note how the attempt does not work, as instead of giving the intended value of MAX(0,C) for each cell C, it instead takes the max of the entire array.

In general, the problem is basically that some functions you want to return an array where the function takes in an array of scalars and outputs an array of scalars, but instead, since the function is already expecting an array (like MAX()), it just outputs a single scalar.

Any way around this?

Thanks
Dave

Excel 2010
DEFGHIJK
5ActualActualActualTrendTrendTrend
6Jan-15Feb-15Mar-15Apr-15May-15Jun-15
7Raw Trend4.003.002.000.97-0.05-1.10
8Bottomed at 04.003.002.000.970.000.00
9
10Attempt in Single Cell4.003.002.000.970.970.97

<tbody>
</tbody>
MrExcel Demo

Worksheet Formulas
CellFormula
F8=MAX(0,F7)
G8=MAX(0,G7)
H8=MAX(0,H7)
I8=MAX(0,I7)
J8=MAX(0,J7)
K8=MAX(0,K7)

<tbody>
</tbody>

<tbody>
</tbody>

Array Formulas
CellFormula
I7:K7{=TREND(F7:H7,F6:H6,I6:K6)}
I10:K10{=MAX(0,TREND(F10:H10,F6:H6,I6:K6))}

<tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>
 
Upvote 0
Too much thinking can cause excess work.

Excel 2012
DEFGHIJK
5ActualActualActualTrendTrendTrend
615-Jan15-Feb15-Mar15-Apr15-May15-Jun
7Trend4.003.002.000.970.000.00

<tbody>
</tbody>
Sheet26

Worksheet Formulas
CellFormula
I7=MAX(TREND($F$7:$H$7,$F$6:$H$6,I6),0)
J7=MAX(TREND($F$7:$H$7,$F$6:$H$6,J6),0)
K7=MAX(TREND($F$7:$H$7,$F$6:$H$6,K6),0)

<tbody>
</tbody>

<tbody>
</tbody>
 
Upvote 0
Hi.

Perhaps you mean:

=IF(FunctionThatReturnsAnArray>0,0,FunctionThatReturnsAnArray)

which will generally require CSE.

Regards
 
Upvote 0
What do you mean by CSE? Yes, that would work in this example, but my main point is in general how to do this; can I just not use functions like MAX() or SUM() that take inputs as arrays?
 
Upvote 0
If you insist on making it all complex, try this:

Excel 2012
DEFGHIJK
5ActualActualActualTrendTrendTrend
615-Jan15-Feb15-Mar15-Apr15-May15-Jun
7Trend4.003.002.000.970.000.00
8
9Trend, complex way4.003.002.000.96785300

<colgroup><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet26

Worksheet Formulas
CellFormula
I7=MAX(TREND($F$7:$H$7,$F$6:$H$6,I6),0)
J7=MAX(TREND($F$7:$H$7,$F$6:$H$6,J6),0)
K7=MAX(TREND($F$7:$H$7,$F$6:$H$6,K6),0)

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>

Array Formulas
CellFormula
I9:K9{=IF(TREND($F$9:$H$9,$F$6:$H$6,$I$6:$K$6)<0,0,TREND($F$9:$H$9,$F$6:$H$6,$I$6:$K$6))}

<thead>
</thead><tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>
 
Upvote 0
Thanks DRSteele. The reason I want to do it as a single array formula instead of separate formulas is to eliminate duplicate calculation; I actually have a custom UDF that takes considerable time, and repeating the same calculation for each column is a lot of wasted effort...

Again, your second example works in this scenario, but not in general; my point is around whether or not I can use SUM() and MAX() etc in this way or I just have to find workarounds.

Thanks again!
 
Upvote 0
CTRL+SHIFT+ENTER, the keystroke combination required to commit array formulas.

yes of course lol. I got excited and thought it was something else.

No, the explanation for which is precisely as you gave previously (and succinctly, I might add).

Bummer.. oh well, worth a shot :)

By the way, do you know of a resource that explains in some level of technical detail how exactly array formulas are implemented in Excel?

Thanks!
Dave
 
Upvote 0

Forum statistics

Threads
1,216,123
Messages
6,128,975
Members
449,480
Latest member
yesitisasport

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