Identify row in array for COUNTIF

dreid1011

Well-known Member
Joined
Jun 4, 2015
Messages
3,614
Office Version
  1. 365
Platform
  1. Windows
In relation to another problem I am working on, how might I identify a variable row within an array based on the location of the current cell being processed in a second array?

I have this range which I would like to count all the values of "B" in a row dependent on another range (below):
Book1 5-31-2024.xlsx
ABCDE
4G
5GB
6BG
7B
8GB
9GB
Sheet1


This range has the cell I want to use to identify the row to count above for values of "B". The cell with 10 determines which row I would like to count above:
Book1 5-31-2024.xlsx
PQRST
1800000
1900000
20000010
2100000
2200000
2300000
Sheet1
Cell Formulas
RangeFormula
P18:T23P18=MAP(MAP($A$4:$E$9,LAMBDA(a,IF(a="G",1,0)))*MAP($M$4:$M$9,LAMBDA(a,IF(a="T",10,0))),LAMBDA(b,b))
Dynamic array formulas.

Ignore the outer MAP( ... ,LAMBDA(b,b)), that is where I am trying to integrate the count of "B" values.

I already have this BYROW to count the values of "B" per row, but I can't figure out how to integrate that into the second array above without getting errors:
Book1 5-31-2024.xlsx
N
180
192
202
212
222
232
Sheet1
Cell Formulas
RangeFormula
N18:N23N18=BYROW(A4:E9,LAMBDA(row,COUNTIF(row,"B")*2))
Dynamic array formulas.


The goal is to use the cell that contains the 10 in the second table to identify the corresponding row in the first table and count the values of "B" and add that count * 2 to the value of 10. In the example, it would count 1 "B" in the third row and add 2 (1*2) to the 10 in the second table for a total of 12. The result should look like the second array but with 12 instead of 10.
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Something like:

Excel Formula:
=MAP(P18:T23,(BYROW((A4:E9="B")*2,LAMBDA(a,SUM(a))))*(P18:T23<>0),LAMBDA(a,b,a+b))
?
 
Upvote 0
How about...
Book2
ABCDE
1
2
3
4G
5GB
6BG
7B
8GB
9GB
10
11
1200000
1300000
14000010
1500000
1600000
1700000
18
19
2000000
2100000
22000012
2300000
2400000
2500000
Sheet3
Cell Formulas
RangeFormula
A20:E25A20=IF(A12:E17=10,A12:E17+BYROW(A4:E9,LAMBDA(b,COUNTIF(b,"B")))*2,0)
Dynamic array formulas.
 
Upvote 0
Solution
Something like:

Excel Formula:
=MAP(P18:T23,(BYROW((A4:E9="B")*2,LAMBDA(a,SUM(a))))*(P18:T23<>0),LAMBDA(a,b,a+b))
?

=IF(A12:E17=10,A12:E17+BYROW(A4:E9,LAMBDA(b,COUNTIF(b,"B")))*2,0)

Both of those are brilliant, thank you! Just goes to show how I was trying to overthink things. I'd mark them both if I could. I'll use Cubist's approach as it's a little shorter though.
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,198
Members
452,617
Latest member
Narendra Babu D

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