Can you add multiple arrays to the REDUCE function?

pto160

Active Member
Joined
Feb 1, 2009
Messages
478
Office Version
  1. 365
Platform
  1. Windows
I was watching a great MrExcel video called PRODUCTIF With MAP REDUCE or SCAN - 2416. This was from two years ago, so things might have changed. These functions were in beta then.
He mentions that with MAP you can pass multiple arrays. He wasn't able to do that with the REDUCE function. He says it is maybe due to the optional initial value.
Is it possible to pass multiple arrays with the REDUCE function?
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
I was reading that it is a good ideal to provide sample data to get your question answered.
Is it possible to use the REDUCE function for this data set without using offset? The answer is 3,780.

Latest Excel_09-14-2023.xlsx
ABCD
3NameValues
4Andy2#NAME?
5Barb1
6Chris1
7Chris1
8Andy2
9Chris1
10Chris1
11Chris1
12Andy3
13Chris1
14Andy5
15Barb1
16Chris1
17Chris1
18Chris1
19Chris1
20Barb1
21Barb1
22Chris1
23Andy7
24Chris1
25Andy9
Sheet4
Cell Formulas
RangeFormula
D4D4=reduce(1,B4:B24,lamda(total,B,IF(OFFSET(B,0,-1,1,1)="Andy",total*B,total)))
 
Last edited:
Upvote 0
Try D4: =REDUCE(1,IF(A4:A25="Andy",B4:B25,1),LAMBDA(a,b,a*b))

Or more simply: =PRODUCT(FILTER(B4:B25,A4:A25="Andy"))
 
Upvote 0
That works fantastic. Thank you so much. (y) :) This really helped me understand how to use a PRODUCT if.
 
Upvote 0
Thank you so much Rick Rothstein. That formula works great. :) (y)
StephenCrump, RIck Rothstein, what is the use of the REDUCE function? Can it replace other functions?

Stephen Crump, your formula


=REDUCE(1,IF(A4:A25="Andy",B4:B25,1),LAMBDA(a,b,a*b))

Is there two arrays being passed?
 
Upvote 0
If you have done any programming, REDUCE is **kind of** the formula equivalent of a FOR EACH loop. In essence, it allows you to process each element of the array passed into the second argument one at a time. The equivalency is not perfect because there are some restrictions on how you can process the elements, but that is the underlying idea behind the REDUCE function.
 
Upvote 0

Forum statistics

Threads
1,215,373
Messages
6,124,548
Members
449,170
Latest member
Gkiller

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