Formula to determine max number in multiple dynamic arrays

jberylec

New Member
Joined
Jan 14, 2023
Messages
23
Office Version
  1. 2019
Platform
  1. Windows
This one is proving tough for me! Hope the experts can help :)

I need to create a formula in F2 that can be copied down through hundreds of location/batch rows, on a new version of this spreadsheet each day. The formula needs to find the max number in D but only for each location/batch section and report only that one into F on the same row. I've manually typed them in F just for display purposes.

A and B rows are always merged for that entire location and batch, as shown. So I was trying to build a formula that would recognize each time a row in B isn't blank <>"" which indicates a new location/batch starts here, then include that row and all blank rows below it (they're merged so treated as blank cells) to find the MAX number in D and show that in F. Then of course it starts over IF B isnt blank again.

In case of a tie, show both.

FYI, there are a lot more columns of data, not relevant for this though because none can be used as an identifier, I also have many other formula columns that I paste into row 2 each morning, then drag them all down the entire sheet, so trying to keep this just a formula not VBA. Hoping to add this new column to my daily paste and drag routine. Ah. Exhausting just describing this. Ha! Thanks in advance
 

Attachments

  • excel.png
    excel.png
    20.7 KB · Views: 20
Thanks for trying, but I cannot really tell anything from a picture like that. Really need some sample data that I can actually copy to test with.
Seems like all the columns have changed significantly as well so it is possible that any adaptation to different columns/ranges could be a problem.

I will wait for your updated XL2BB sample data.
 
Upvote 0

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Ok I was able to find and replicate the issue in which the original formula is counting blanks as the largest. Finally, here ya go! Sorry to jump back and forth, we'll tackle this one first, then the other opposite issue :) Thanks!

ALL012723-qw2jqz.xlsx
ABCDEFG
1LOCVALVAL IFLENCODEIFNA
21183832561
3181812562
4177772553
5175.575.5455 
610 0#VALUE!1
710 0#VALUE!1
816969254 
92270702551
1020 0#VALUE!1
11266662542
12245452523
133354542532
1430 0#VALUE!1
1530 0#VALUE!1
1631818249 
17395952571
18342422523
Sheet1
Cell Formulas
RangeFormula
D2:D18D2=IF(C2=0,"",C2)
E2:E18E2=LEN(D2)
F2:F18F2=CODE(D2)
G2:G18G2=IFNA(MATCH(COUNTIFS(B$2:B$20,B2,D$2:D$20,">"&D2)+1,{1,2,3},0),"")
B2:B18B2=B1+(A2<>"")
 
Upvote 0
You have dropped off part of the formula
Post 15 and post 17
=IF(D2="","",IFNA(MATCH(COUNTIFS(E$2:E$1000,E2,D$2:D$1000,">"&D2)+1,{1,2,3},0),""))

Post 22
=IFNA(MATCH(COUNTIFS(B$2:B$20,B2,D$2:D$20,">"&D2)+1,{1,2,3},0),"")
You have adjusted the columns correctly, but it is missing the red part!
 
Upvote 0
Hi Peter, yes I purposely did that because it was hiding or causing something else I needed, cant remember right now. But I'll change all of them back and revisit. Thank you!
 
Upvote 0
Another quick one for ya I'm sure, but I need a formula for column E that will count how many rows in each unique array where column D is not blank (remember column B is already our unique helper column ). Thank you!

TESTING2.xlsx
ABCDE
1LOCVALVAL IFNEW EXPECTED VALUE
21183835
3181815
4177775
5175.575.55
610 5
710 5
8169695
92270703
1020 3
11266663
12245453
133354544
1430 4
1530 4
16318184
17395954
18342424
Sheet1
Cell Formulas
RangeFormula
B2:B18B2=B1+(A2<>"")
D2:D18D2=IF(C2=0,"",C2)
 
Upvote 0
You would need to adjust the range in the formula but this would do it

Excel Formula:
=COUNTIF(B$2:B$20,B2)

Or this one would consume a little less resources
Excel Formula:
=IF(B2=B1,E1,COUNTIF(B$2:B$20,B2))
 
Upvote 0
You would need to adjust the range in the formula but this would do it

Excel Formula:
=COUNTIF(B$2:B$20,B2)

Or this one would consume a little less resources
Excel Formula:
=IF(B2=B1,E1,COUNTIF(B$2:B$20,B2))

The top option counts the rows, but unfortunately doen't check D to see if it's blank and exclude from the row count. I think we need multiple criteria and ranges in order to count only non-blanks in D which are in the same B range.

The bottom option seems to reference E but that was just my example of what this formula result should be, so we cant reference those cells. E is where this new formula will live :)

I tried fiddling around with stuff like the following but nah, COUNTIFS(B$2:B$1500,B2,D$2:D$1500,D2&"<>""")
Thanks in advance!
 
Upvote 0
Sorry, I mis-read the earlier information. :oops:

I tried fiddling around with stuff like the following but nah, COUNTIFS(B$2:B$1500,B2,D$2:D$1500,D2&"<>""")
Close. :)

Try these (I would probably use the first one)
Excel Formula:
=IF(B2=B1,E1,COUNTIFS(B$2:B$1500,B2,D$2:D$1500,">0"))
Excel Formula:
=COUNTIFS(B$2:B$1500,B2,D$2:D$1500,">0")
 
Upvote 0

Forum statistics

Threads
1,215,889
Messages
6,127,593
Members
449,386
Latest member
owais87

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