SumProduct Date Comparison Double Unary Operator

tcardwell

Board Regular
Joined
Dec 22, 2013
Messages
86
Hello,

Was trying to optimize a sumproduct formula that uses date comparison conditions. The following formula works fine:

=SUMPRODUCT(SUMIFS(PerAct,Entity,--(INDIRECT("EntLst")),Date,INDIRECT("D1"),Date, INDIRECT("D2"),Account,--(INDIRECT($A4))))

D1 is a cell with a date formatted as >=04/30/2016 and
D2 is a cell with a date formatted as <= 05/31/16.

But when I add --(indirect("D1")) and --(indirect("D2") to the above formula it does not yield accurate results only zeros.

PerAct, Entity, Date and Account are named ranges in a table. Does anyone have any ideas on why the date range doesn't want to be optimized?

Thanks, Tom C
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
I'm not sure why you have all the INDIRECT's.

I'd do the date bit like this:

=SUMPRODUCT(Something,--(YourDate>=D1),--(YourDate<=D2))

where D1 and D2 are the required start date and end date.

What are doing with Entity and Account? Perhaps checking if they're on the relevant list?
 
Upvote 0
Hello and thanks for the reply,

Yes, Entity and Account are named ranges and, depending on the criteria, will determine which records will be selected and that part of the formula is working fine. I wanted to do something similar with the dates since the table is 12,000 rows and I only want to sum the records that meet the date criteria. The date comparison logic works fine without the unary optimizers, I was just wondering why it doesn't work when I add the double unary. I need all the indirects to point to the criteria to the underlying arrays.
 
Upvote 0
Why not just use SUMIFS?

=SUMIFS(PerAct,Entity,"EntLst",Date,">="&D1,Date, "<="&D2,Account,$A4)
 
Upvote 0
Why not just use SUMIFS?

Yep! I'm assuming the task is something like:

B6: =SUMIFS(G2:G10,D2:D10,Entity,E2:E10,Account,F2:F10,">="&StartDate,F2:F10,"<=" &EndDate)

ABCDEFG
1EntityXYZEntityAccountDateAmount
2Account100ABC10023 Apr 2016$13
3Start1 May 2016ABC20028 Apr 2016$77
4End31 May 2016XYZ1003 May 2016$13
5ABC2008 May 2016$15
6Total$21XYZ10013 May 2016$1
7XYZ20018 May 2016$30
8XYZ10023 May 2016$7
9ABC20028 May 2016$94
10XYZ1002 Jun 2016$46

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>

 
Upvote 0
Yeah, I don't understand the use of indirect or the -- operations either..

I think this is what you're trying to do.

=SUMPRODUCT(SUMIFS(PerAct,Entity,EntLst,Date,D1,Date, D2,Account,$A4))
 
Upvote 0
Thank you Mr Crump, Mr Dibbins and Mr Jonmo1,

I tried each of your suggestions but to no avail. I was able to shorten up the function and the following seems to work best:

=SUMPRODUCT(SUMIFS(PerAct,Entity,--(INDIRECT("EntLst")),Date,D$1,Date,D$2,Account,--(INDIRECT($A4))))

Not sure if I made this clear but EntLst is a named range that can contain up to a list of 5 entities. So, as I understand it, I needed the Indirect wrapper to point to the underlying range/array that contains the list of entities. Also, A4 is a cell that contains a word that is a named range that points to all the accounts that can be summed up into that line on the P&L statement. Ultimately I am building a P&L statement from a trial balance. The trial balance has as column headers: Account, Desc, BegBal, Activity, EndBal, Entity, Date, which I turned into Named Ranges. Right now this file has about 12k rows of data so I was wanting to make it run as fast as possible. Thanks to your help I was able to shorten the Date conditions, which as it turned out, did not need the Indirect wrapper function.

Thanks, Tom C
 
Upvote 0

Forum statistics

Threads
1,215,514
Messages
6,125,265
Members
449,219
Latest member
daynle

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