Will subtotal work with arrays?

Joel John

New Member
Joined
Jan 17, 2024
Messages
4
Office Version
  1. 365
Platform
  1. Windows
I got column A with contract values (in dollars) and column B with the amount invoiced in a month. The column B will have both the numeric values (in dollars) and percentages with respect to the contract value (same row in column A).
I have a formula to get the total sum of amount invoiced in a month in column B as below:
=SUM(IF(B:B<=1,B:B*A:A,0),IF(B:B>1,B:B))
But the formula that I got doesn't work when I use filters on the list. Will subtotal work on arrays in anyway?
 

Attachments

  • Screenshot 2024-01-19 080635.png
    Screenshot 2024-01-19 080635.png
    9.4 KB · Views: 20

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Add a helper column and add this formula in C2 down:
=SUBTOTAL(103,A2)

Then you can use that to multiple the values in column C. Visible = 1, hidden = 0

Book2
ABCDEF
1Contract ValuesAmount InvoicedVisibleSum:$ 178,309.00
2$ 10,000.00$ -1
3$ 10,000.00$ -1
4$ 10,000.0020%1
5$ 10,000.00$ 50,000.001
6$ 10,000.0030%1
7$ 10,000.00$ 2,501.001
8$ 10,000.0025%1
9$ 10,000.00$ 50,001.001
10$ 10,000.0080%1
11$ 10,000.00$ 2,502.001
12$ 10,000.0022%1
13$ 10,000.00$ 50,002.001
14$ 10,000.0031%1
15$ 10,000.00$ 2,503.001
Sheet1
Cell Formulas
RangeFormula
F1F1=SUM(IF(B2:B15<=1,B2:B15*A2:A15*C2:C15,0),IF(B2:B15>1,B2:B15*C2:C15))
C2:C15C2=SUBTOTAL(103,A2)
 
Upvote 0
Hi Jeffrey,

Thanks for the answer but this is not what I was looking for. We have multiple columns with 100s of lines of data which spreads across few years of data.
So, I did something similar to what you mentioned before by including a duplicate sheet to carry the years of data but this just increases the file size too much which is already a huge file and creates a lot of syncing issues within our server.
I was wondering if we can use subtotal function in some way to use the array that I get from the if function.
 
Upvote 0
How about
Excel Formula:
=SUM(BYROW(A2:B15,LAMBDA(br,IF(SUBTOTAL(103,br),IF(INDEX(br,,2)<=1,INDEX(br,,2)*INDEX(br,,1),INDEX(br,,2))))))
 
Upvote 1
How about
Excel Formula:
=SUM(BYROW(A2:B15,LAMBDA(br,IF(SUBTOTAL(103,br),IF(INDEX(br,,2)<=1,INDEX(br,,2)*INDEX(br,,1),INDEX(br,,2))))))
Thank you for the answer! That worked in my example. But in my actual sheet, I have about 14 columns in between my contract value column and amount invoice column, and then there are multiple columns with the amounts invoiced in each month. Is it possible with this formula to get the total invoiced for each month separately on top of each column?
 
Upvote 0
For the 1st part you can something like
Fluff.xlsm
AOPQ
1Contract ValuesAmount Invoiced20306
2100000
3100000
4100000.2
6100000.3
7100002501
8100000.25
11100002502
12100000.22
14100000.31
15100002503
Sheet4
Cell Formulas
RangeFormula
Q1Q1=SUM(BYROW(A2:O15,LAMBDA(br,IF(SUBTOTAL(103,br),IF(INDEX(br,,15)<=1,INDEX(br,,15)*INDEX(br,,1),INDEX(br,,15))))))
 
Upvote 1
Solution
I understand, now I can just add another row to indicate the column number for each month and use that instead of 15 and so on. cheers
Thank you for the help. Really appreciate it!
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 1

Forum statistics

Threads
1,223,893
Messages
6,175,241
Members
452,622
Latest member
Laura_PinksBTHFT

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