Multiply an array based on date value entered.

AlInVegas2

New Member
Joined
Jun 19, 2019
Messages
25
In one cell, I'm trying to get a product if from the array below. If I enter a date of 7/1/23, the result is the product of the Factor column for all dates that are less than or equal to the date entered.
In the case of 7/1/23, the result would be 1*7*3 or 21. In the case of 1/1/24, it would be 1*7*3*9 or 189.... attempting to use SumProduct( or Product(if commands with little success.


DateFactor
09/01/20201
12/11/20217
06/04/20223
07/03/20239
01/02/20244
10/15/20246
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Which version of Excel are you using?
Try:
Book1
ABCDE
1DateFactor
29/1/202017/1/202321
312/11/202171/1/2024189
46/4/20223
57/3/20239
61/2/20244
710/15/20246
Sheet2
Cell Formulas
RangeFormula
E2:E3E2=PRODUCT(IF($A$2:$A$7<=D2,$B$2:$B$7,1))
 
Upvote 0
Which version of Excel are you using?
Try:
Book1
ABCDE
1DateFactor
29/1/202017/1/202321
312/11/202171/1/2024189
46/4/20223
57/3/20239
61/2/20244
710/15/20246
Sheet2
Cell Formulas
RangeFormula
E2:E3E2=PRODUCT(IF($A$2:$A$7<=D2,$B$2:$B$7,1))

I found the issue, I have an area defined that has blank cells in it for the comparative value. How can I get the same formula to ignore rows without data?
 
Upvote 0
I found the issue, I have an area defined that has blank cells in it for the comparative value.
Can you show what you mean by this?

Also, please answer which Excel version you are using. The optimal solution may vary.
 
Upvote 0
Can you show what you mean by this?

Also, please answer which Excel version you are using. The optimal solution may vary.
I'm using office 365..

So in this table:


DateFactor
09/01/20201
12/11/20217
06/04/20223
07/03/20239
01/02/20244
10/15/20246
10/15/20246
02/11/20214

SplitDate is the range of cells in the date column (including the blank ones). SplitFactor is that same in the factor column.

Using:

=PRODUCT(IF(SplitDate<=@TrDate,SplitFactor,1)) where @TrDate equals 12/11/21, the result is 0. Filling the table with values, the result is a product where the date value test holds true.

To fix this, I used Offset to count the number of dates entered.
=PRODUCT(IF(OFFSET(SplitDate,0,0,COUNT(SplitDate),1)<=@TrDate,OFFSET(SplitFactor,0,0,COUNT(SplitDate),1),1))

With @TrDate = 12/11/21, the result from the entire table below (blank cells included is 28, (1*7*4). So this works...

Now to complicate things.. I added another condition, whereby I could exclude certain rows from being included when they met the date criteria...

=PRODUCT(IF((OFFSET(SplitDate,0,0,COUNT(SplitDate),1)<=@TrDate)*(OFFSET(SplitExclude,0,0,COUNT(SplitDate),1)="")=1,OFFSET(SplitFactor,0,0,COUNT(SplitDate),1),1))

From the table below, with @TrDate = 12/11/21, the result was 7 (1*7) with the 4 excluded the product calculation. Appreciate your help in getting me closer.



DateFactorExclude
09/01/20201
12/11/20217
06/04/20223
07/03/20239
01/02/20244
10/15/20246
10/15/20246
02/11/20214 P
 
Upvote 0
How about
Book1
ABCDE
1DateFactorExclude
29/1/20112/11/217
312/11/2171/1/24189
46/4/223
57/3/239
61/2/244
710/15/246
82/11/114P
9
10
Sheet1
Cell Formulas
RangeFormula
E2:E3E2=PRODUCT(IF(($A$2:$A$10<=D2)*($A$2:$A$10<>"")*($C$2:$C$10<>"P"),$B$2:$B$10,1))
 
Upvote 0
How about
Book1
ABCDE
1DateFactorExclude
29/1/20112/11/217
312/11/2171/1/24189
46/4/223
57/3/239
61/2/244
710/15/246
82/11/114P
9
10
Sheet1
Cell Formulas
RangeFormula
E2:E3E2=PRODUCT(IF(($A$2:$A$10<=D2)*($A$2:$A$10<>"")*($C$2:$C$10<>"P"),$B$2:$B$10,1))
That is essentially what I have except the offsets allow me to have the amount of split data to be more dynamic. Appreciate your skewing me towards the answer.
 
Upvote 0
I'm using office 365..

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0

Forum statistics

Threads
1,223,628
Messages
6,173,429
Members
452,514
Latest member
cjkelly15

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