Based on visible rows calculate (COUNTIF, MINIF, AVERAGEIF, MAXIF)

WaqasTariq

Board Regular
Joined
Jun 26, 2012
Messages
58
Office Version
  1. 365
I am looking to calculate the "Cst Info" data based on the filtered data available on the "Data" worksheet. I have so far tried searching the forum, but have been unable to find something similar.

Example workbook uploaded here.

This is how my "Data" worksheet looks like (after filtering for "Invoice Date"):

InvBill ToN/AN/AInvoice DateN/AN/AN/AN/ADays OpenDays Overdue
2568​
Company A
06/28/22​
16​
59​
6286​
Company A
06/30/22​
104​
2​
10004​
Company A
12/29/22​
32​
0​
13722​
Company A
06/14/23​
22​
170​
17440​
Company B
09/14/23​
200​
144​
39748​
Company A
11/30/22​
119​
89​

On another worksheet, "Cst Info" I am calculating the totals based on Column B, and need the calculations to be based on visible rows.

Bill ToInv CountMin (overdue)Avg (overdue)Max (overdue)Min (open)Avg (open)Max (open)
Company A
10​
0​
65.3​
170​
16​
78​
119​
Company B
7​
62​
94.29​
144​
92​
128.29​
200​
Company C
12​
62​
76.42​
129​
92​
112.75​
174​

Formulas:
COUNTIF(Data!B:B,A2)AVERAGEIF(Data!B:B,A2,Data!K:K)MAXIFS(Data!K:K,Data!B:B,A2)MINIFS(Data!J:J,Data!B:B,A2)AVERAGEIF(Data!B:B,A2,Data!J:J)MAXIFS(Data!J:J,Data!B:B,A2)
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Downloading spreadsheets doesn't work for me, but the AGGREGATE function looks like your friend. The first argument will give you average, min, max, count,... - the second argument will give you options to ignore hidden cells (5). Then the array in question.
 
Upvote 0
Downloading spreadsheets doesn't work for me, but the AGGREGATE function looks like your friend. The first argument will give you average, min, max, count,... - the second argument will give you options to ignore hidden cells (5). Then the array in question.
Thank you for pointing me in the right direction. I have tried a few different ways, but not getting any values when using the AGGREGATE.

Formula: =AGGREGATE(2,5,Data!B:B,A2)

Where:
2 = Count
5 = Don't include hidden rows
Data!B:B = Rows to count
A2 = Match cell value of A2 in Data!B:B to count

What am I doing wrong here?
 
Upvote 0
How about like
For B2
Excel Formula:
=ROWS(FILTER(Data!$B$2:$B$100,(Data!$B$2:$B$100=A2)*(MAP(Data!$B$2:$B$100,LAMBDA(m,SUBTOTAL(103,m))))))
And for C2
Excel Formula:
=MIN(FILTER(Data!$K$2:$K$100,(Data!$B$2:$B$100=A2)*(MAP(Data!$B$2:$B$100,LAMBDA(m,SUBTOTAL(103,m))))))
 
Upvote 0
How about like
For B2
Excel Formula:
=ROWS(FILTER(Data!$B$2:$B$100,(Data!$B$2:$B$100=A2)*(MAP(Data!$B$2:$B$100,LAMBDA(m,SUBTOTAL(103,m))))))
And for C2
Excel Formula:
=MIN(FILTER(Data!$K$2:$K$100,(Data!$B$2:$B$100=A2)*(MAP(Data!$B$2:$B$100,LAMBDA(m,SUBTOTAL(103,m))))))

Thank you! This is working as expected, but I have over 350 customers (unique column A customers), when I try to autofill the entire 350 rows with the logic, my computer halts with 100% cpu usage to Excel :cry:. Waiting for 30 mins and then killed Excel.

Is there a formula that could do this and not take so much cpu processing time?
 
Upvote 0
You could use a helper cell with
Excel Formula:
=SUBTOTAL(3,B2)
and then add that as another criteria to your existing formulae like
Excel Formula:
=MINIFS(Data!K:K,Data!B:B,A2,Data!L:L,1)
 
Upvote 1
Solution
You could use a helper cell with
Excel Formula:
=SUBTOTAL(3,B2)
and then add that as another criteria to your existing formulae like
Excel Formula:
=MINIFS(Data!K:K,Data!B:B,A2,Data!L:L,1)
Thank you so much for the help Fluff. I appreciate it a lot.

Thoughts and prayers!
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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