SumIf like formula for horizontal data where your value has to search within a text string

marilyn123

New Member
Joined
Aug 15, 2016
Messages
15
Hi,

I hope somebody is able to help with the below. I've been given a report with a bunch of horizontal data (changing the entire report structure is not really an option at this point). In the column where it says "Language 1" I need a formula that can search the first row of all the columns for the word "language 1" and sum a certain row value, similar to what a sumif does. So in this example it needs to sum up the two values under 'Language 1 (only)' and 'Language 1 Hispanic', etc. There will be a lot of other languages in different columns but of course it would have been too big to show for here.

So for example the first row of the data under language 1 is 0 (0+0) and the second is 1 (1+0). I came up with a horizontal lookup that will bring the first value it finds, but can't seem to figure out something that will find all of the values sum all of it together. =HLOOKUP("*" & F2 & "*",$G$2:$U$8,ROW()-1,FALSE). The first part of the formula is so that it will agree with anything that has the word "Arabic", the Row()-1 is so it will bring back the appropriate row value.

Any advice on how to get these values to sum? Much appreciated...
I hope this all makes sense!


Program
Location
Total
Language 1
Total %
Language 1(only)
%
Language 1, Hispanic
%
1
A
68
0
0.0%
0
0.00 %
0
0.00 %
1
B
4
1
25.0%
1
25.00 %
0
0.00 %
1
C
135
1
0.7%
1
0.74 %
0
0.00 %
1
D
118
0
0.0%
0
0.00 %
0
0.00 %
1
E
125
3
2.4%
2
1.60 %
0
0.00 %
1
F
705
0
0.0%
0
0.00 %
0
0.00 %

<tbody>
</tbody>

<tbody>
</tbody>
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Why is the 5th row total 3? Is it not 2? And if I understand correctly, you just want to sum each row separately for any column containing "Language 1"?
 
Upvote 0
Why is the 5th row total 3? Is it not 2? And if I understand correctly, you just want to sum each row separately for any column containing "Language 1"?


Hi, you are correct in that it should say 2. It's possible I left out a row from the actual spreadsheet. But your logic is correct.
 
Upvote 0
Hi, you are correct in that it should say 2. It's possible I left out a row from the actual spreadsheet. But your logic is correct.

Ok, assuming your data starts in A1, then put this in your Language 1 column (D2?) and copy down. Adjust the F1:I1 and F2:I2 ranges to suit your data.

=SUMPRODUCT((IFERROR(SEARCH("Language 1",$F$1:$I$1),0))*--(F2:I2>0)*(F2:I2))

This is an array formula entered with CTRL+SHIFT+ENTER, not just ENTER.
 
Upvote 0
Hi,

The formula works which is great. Now that I've tested it out, I'm finding another problem. I need the word "Language 1" to be the FIRST word in the text string. So for this example, I'd change Language 1 to "LanguageA" to make it easier. One word with no numbers in it.

The reason for this is because - for example - if I want to sum the values from ["Arabic", "Arabic, Hispanic", "Arabic, Other"] but do NOT want to pull "Farsi, Arabic" as that is under the category of Farsi. I hope this makes sense.
 
Upvote 0
Hi,

The formula works which is great. Now that I've tested it out, I'm finding another problem. I need the word "Language 1" to be the FIRST word in the text string. So for this example, I'd change Language 1 to "LanguageA" to make it easier. One word with no numbers in it.

The reason for this is because - for example - if I want to sum the values from ["Arabic", "Arabic, Hispanic", "Arabic, Other"] but do NOT want to pull "Farsi, Arabic" as that is under the category of Farsi. I hope this makes sense.

Ok. Will the category always be the first word then? And before the comma if there is a comma?
 
Upvote 0
Yes to both of your questions

Ok, give this a try:

=SUMPRODUCT(--(LEFT($F$1:$I$1,LEN(TRIM($D$1)))=TRIM($D$1))*--(F2:I2>0)*(F2:I2))

This is an array formula entered with CTRL+SHIFT+ENTER, not just ENTER.

Also, it assumes the Category you want to sum is in D1.
 
Upvote 0
Ok, give this a try:

=SUMPRODUCT(--(LEFT($F$1:$I$1,LEN(TRIM($D$1)))=TRIM($D$1))*--(F2:I2>0)*(F2:I2))

This is an array formula entered with CTRL+SHIFT+ENTER, not just ENTER.

Also, it assumes the Category you want to sum is in D1.

Seems to be working great. I'm really impressed!
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,864
Members
449,052
Latest member
Fuddy_Duddy

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