First Letter in a string

gberg

Board Regular
Joined
Jul 16, 2014
Messages
205
Office Version
  1. 365
Platform
  1. Windows
I have this formula that I need to modify a bit. Currently it takes the first character in a string and compares it to a cell I've called "Product_Specific". The Product_Specific cell will contain one letter (i.e. A, B, C, D, ect.) The formula sums up all of the rows that start with the letter entered into the "Product_Specific" cell. The text in red below is the part of the formula that looks for the letter

=SUMPRODUCT(--(LEFT(Tbl_Backlog[Proj '#],1)=Product_Specific),--(Tbl_Backlog[Status]=Year_Current),--(Tbl_Backlog[Revenue]<POC_Amount),Tbl_Backlog[Revenue])

My issue is the cells all used to start with a letter (i.e. D0001, D0002, Dold, Dxxx, etc.) but now they could remain this way or they could start with something else (i.e. 71D0001, 71-D0001, etc.) If there is something in front of the first letter it will always be a number or a character such as a "-". What I want is to find the first letter in the string to compare it to the "Product_Specific" cell.

I have this formula that works to pull the first letter from a single cell
=MID(A18,MATCH(TRUE,ISERROR(VALUE(MID(A18,ROW(INDIRECT("1:"&LEN(A18))),1))),0),1)

I tried using this in the original formula above but replace the "A18" cell reference with "Tbl_Backlog[Proj '#]" but it does not work for me
=SUMPRODUCT(--(MID(Tbl_Backlog[Proj '#],MATCH(TRUE,ISERROR(VALUE(MID(Tbl_Backlog[Proj '#],ROW(INDIRECT("1:"&LEN(Tbl_Backlog[Proj '#]))),1))),0),1)=Product_Specific),--(Tbl_Backlog[Status]=Year_Current),--(Tbl_Backlog[Revenue]<POC_Amount),Tbl_Backlog[Revenue])

I hope this makes sense and would be grateful for any help

Thanks,

Greg
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Hi,

The formula for determining the first character is a array formula which, if properly confirmed, will not return an array with the numbers of every cell in the table.
This can be fixed with adding a helper column like this:

Book1.xlsx
ABCDEFG
7proj #statusRevenueHelper Column
88976A908718A16
990A1234518A
Sheet3
Cell Formulas
RangeFormula
G8G8=SUMPRODUCT(--(Tbl_Backlog[Helper Column]=Product_Specific),--(Tbl_Backlog[status]=Year_current),--(Tbl_Backlog[Revenue]<poc_amount),Tbl_Backlog[Revenue])
D8:D9D8=MID([@[proj '#]],MATCH(TRUE,ISERROR(VALUE(MID([@[proj '#]],ROW(INDIRECT("1:"&LEN([@[proj '#]]))),1))),0),1)
Press CTRL+SHIFT+ENTER to enter array formulas.
Named Ranges
NameRefers ToCells
poc_amount=Sheet3!$B$3G8
Product_Specific=Sheet3!$B$1G8
Year_current=Sheet3!$B$2G8


Hope this helps.
 
Upvote 0
jorismoerings,

Thanks for the idea. I usually try to avoid "helper" columns, just one more thing that someone can screwup and it's amazing how people can screw up a spreadsheet! If it is the only way, I guess it's the only way.

Thanks again

Greg
 
Upvote 0
Perhaps is a power-query and using the data model a better solution.
It takes calculations to the data model and not in the table anymore. No calculations - no screw ups.
But every solution has it specific perks so ….
 
Upvote 0
I usually try to avoid "helper" columns
So see if this works for you

Excel Formula:
=LET(rev,Tbl_Backlog[Revenue],proj,Tbl_Backlog[proj '#],m,MID(proj,SEQUENCE(LEN(proj)),1),SUM(FILTER(rev,(LEFT(CONCAT(IF(ABS(CODE(m)-77.5)<13,m,"")),1)=Product_Specific)*(Tbl_Backlog[status]=Year_current)*(rev<poc_amount),0)))
 
Upvote 0
Give me a #CALC! error
Then perhaps you could give us a small set of your sample data with XL2BB?

Here is the formula working for me (at least as I understand the problem), so it would be good to work out what is fundamentally different between our worksheets.
Is 12 the result that you would expect from my sample data?

gberg.xlsm
BCDEFG
1A
21
310
4
5
6proj #statusRevenue
78976A908718
890A1234512012
97Bhjuy110
10Aysewere14
1171-A DD25
12
Sheet1
Cell Formulas
RangeFormula
G8G8=LET(proj,Tbl_Backlog[proj '#],m,MID(proj,SEQUENCE(LEN(proj)),1),SUM(FILTER(Tbl_Backlog[Revenue],(LEFT(CONCAT(IF(ABS(CODE(m)-77.5)<13,m,"")),1)=Product_Specific)*(Tbl_Backlog[status]=Year_current)*(Tbl_Backlog[Revenue]<poc_amount),0)))
Named Ranges
NameRefers ToCells
poc_amount=Sheet1!$B$3G8
Product_Specific=Sheet1!$B$1G8
Year_current=Sheet1!$B$2G8
 
Upvote 0
Book1
ABC
1Revenue
2ProductD$ 50,000
3
4Year2021
5POC Amount3,000,000
6
7Proj #StatusRevenue
871D0001202110,000
971G0002202120,000
1071-P5621202130,000
11328D354202140,000
Sheet1
 
Upvote 0
Not checked:

'=SUMPRODUCT(--(ISNUMBER(FIND(Product_Specific,Tbl_Backlog[Proj '#]))),--(Tbl_Backlog[Status]=Year_Current),--(Tbl_Backlog[Revenue]<POC_Amount),Tbl_Backlog[Revenue])
 
Upvote 0
Column B2 = Product_Specific
Column B4 = Year_Current
Column B5 = POC_Amount

in this example I want the Product "D" summed.

That would be line 8 and line 11 or $50,000 since those lines have "D" as the first letter in the string
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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