Excel, sum range split - google-docs

I have a google spreadsheet and I want calculate to some data...
I want to sum the splits in a range
1 | A1 |
2 | 1Q1 |
3 | 3Q2 |
4 | 5Q7 |
I need the sum of the integers after the letter "Q" so in the example above I would get 1+2+7=10

This formula will do it all in one, just set the range in the formula , ie A2:A4
=SUM(VALUE((RIGHT(A2:A4,LEN(A2:A4)-FIND("Q",A2:A4,1)))))
Press CTRL+SHIFT+ENTER to enter the array formula.

You can use the function VALUE(RIGHT(text)) which will give you back the number value of the rightmost character in the string. Then use those values in your sum.

Assuming that the 3rd character is the number, you could try something like
=VALUE(MID(A:A,3,len(A:A)))
in column B
then sum that like this (for the 1st 3 rows):
=SUM(B1:B3)

Related

Using SUMIF on a range of columns or SUMPRODUCT to ignore text items

I have a range with various text and numbers in them. I wish to total the numbers based on the identifying first column.
I have tried
=SUMIF(A1:A20,"John",B1:E20)
which only returns the first columns number. I've also tried
=SUMPRODUCT((A1:A20="John")*(B1:E20))
but as there is text in column C, it returns #VALUE!.
A | B | C | D | E
John | 5 | Wine | 2 | 7
Sean | 6 | Beer | 5 | 2
I want all of the numeric values in columns B-E to be totalled together when "John" is in column A
Here is an array formula solution - use Ctrl, Shift and Enter to confirm:
=SUM(IF(A1:A20="John",IF(ISNUMBER(B1:E20),B1:E20)))
If you just want to exclude column C you could use this non-array formula:
=SUMPRODUCT((A1:A20="John")*(B1:B20))+SUMPRODUCT((A1:A20="John")*(D1:E20))
Alternatively, perhaps move C so it's not in the middle of your numbers.
Try this formula:
=IF(A1="John", SUMPRODUCT(--(ISNUMBER(B1:E1)),B1:E1), "")
and drag down to get sum on each row.

Excel printing a specific number in a row subject to other columns

I have an excel file with 3 columns and 100 thousand rows. My goal is to print the number of column A, where the number in column C is the maximum and the number in column B is higher or equal to 0.9. Like this example:
-----+------+-----
A | B | C
-----+------+-----
1 | 0.9 | 130
2 | 0 | 200
3 | 0.95 | 90
In this example for example it should print '1' since column 1 and 3 are higher than 0.9 but 1 is higher than 3 in column C. Anyway to do this in excel?
Assuming your data in column C is positive (or at least, that the maximum value is positive), you can use this array formula:
= INDEX(A:A,MATCH(LARGE(((B:B>=0.9)+0)*(C:C),1),((B:B>=0.9)+0)*(C:C),0))
Note this is an array formula, so you must press Ctrl+Shift+Enter after typing in the formula.
This gets pretty ugly since there is no =MAXIFS() formula. Instead, an array formula will do the trick:
=SUMIFS(A1:A3, C1:C3,MAX(IF(B1:B3>=0.9, C1:C3, 0)), B1:B3,">=.9")
Hit Ctrl+Shift+Enter when entering that so Excel will interpret as an array formula.
The Sumifs() here isn't summing more than one value so no worries there. We are grabbing the value from A1:A3 where C1:C3 is equal to the MAX() of that column where B1:B3 is greater than or equal to .9. Which solves that max() issue. And then we are then only allowing selection A1:A3 where B1:B3 is greater than or equal to .9.
It's not pretty, and it requires us to check that >=.9 condition twice, but it does the job.
Try using this array formula =SUMPRODUCT(INDEX(A2:A20,MATCH(MAX(--($B$2:$B$20>=0.9)*C2:C20),--($B$2:$B$20>=0.9)*C2:C20,0),1)) in cell D2. Confirm it with CTRL+SHIFT+ENTER.
This is the array formula (means you have to click Ctrl + Shift + Enter altogether) what I came up with:
=INDEX(A:C,MATCH(MAX(--(B:B>=0.9)*(C:C)),(B:B>=0.9)*(C:C),0),1)
Please note that I used the whole column but I will suggest to only use the ranges that are needed for faster speed.

COUNTIF range does not equal range

The data I'm looking to get is something like this:
+----------+-------+
| Location | Count |
+----------+-------+
| Jungle | 2 |
| Ocean | 4 |
| Other | 2 |
+----------+-------+
The formula for count should look in the data range and if a cell's data does not equal any of the cell data in the rest of the location column (Jungle, Ocean) it should add that to the count. It should exclude blanks.
This is the formula I tried:
=COUNTIF(A1:H6,"<>"&E11:E12)
Here is my example sheet: https://docs.google.com/spreadsheets/d/1YbqEwa3olEXMcmU-UORfe7jwyK_-AXDomp1t5iTVUaU/edit?usp=sharing
Where am I going wrong? There are 7 other instances of colours not Green or Blue therefore I would expect this result to be output. I haven't put anything in about ignoring spaces so I would expect the result to count blanks too, but I get 0.
Don't use & - this would join E11 and E12 together so you would be looking for greenblue. You would need a COUNTIFS to get the three conditions
=COUNTIFS(A1:H6,"<>"&E11,A1:H6,"<>"&E12,A1:H6,"<>")
Here is a more general way of doing it
=COUNTA(A1:H6)-SUMPRODUCT(COUNTIF(A1:H6,E11:E12))
See this useful reference
The COUNTIFS formula is your friend here. This formula should work for that cell:
=COUNTIFS(A1:H6,"<>"&E11,A1:H6,"<>"&E12,A1:H6,"<>")
The problem with a 'does not equal OR does not equal' is that when it is not equal to one, it could be equal to the other and vice-versa. Additionally, you range to count from is 2 dimensional so you cannot use rows of criteria. Use SUMPRODUCT and individual criteria multiplied against each other.
=SUMPRODUCT((A1:H6<>"")*(A1:H6<>E11)*(A1:H6<>E12))
Any of those three conditions that is not true is considered zero. Anything multiplied by zero is zero. 1 x 1 x 1 is 1.
For large numbers of exclusions, you will want to use an array formula (with CSE) to count them and then subtract that total from a COUNTA total of the entire range.
=COUNTA(A1:H6)-SUM(COUNTIF(A1:H6,E11:E15))

Excel: Dividing comma separated single cell numbers

I have a string of numbers in a single Excel cell separated by commas, e.g. A2 = "4,3,2,7". I want a formula to be able to divide those number by 2 in cell B2, e.g. B2 = "2,1,1,3" (odd numbers should round down rather than up)
The formula needs to be able to account for:
- smaller or larger string of numbers
- for both single and double digit numbers
- numbers that are even or odd
- no VBA
- formula can use multiple columns but not the delimited text to columns feature (due to cell location)
I was able to get a formula to sum the string of numbers in A2 (4,3,2,7 = 16) but not able to divide by 2. My formula to sum the string is below. Any help is appreciated, thanks!
{=SUM(IF(ISERR(VALUE(MID(A2,ROW($A$1:OFFSET($A$1,LEN(A2)-1,0‌​)),1))),0,VALUE(MID(‌​A2,ROW($A$1:OFFSET($‌​A$1,LEN(A2)-1,0)),1)‌​)))}
In your example, use this formula into cell B1:
=SUBSTITUTE(SUBSTITUTE(A1,",","000")/2,"000",",")
Then result will be like this:
| A | B |
+---------+---------+
1| 4,2,6,8 | 2,1,3,4 |
2|
Well, This is my second attempt to solve(I hope) your problem. If your string is in cell A2, then put this code inot cell B2:
=LEFT(IFERROR(ROUNDDOWN(MID(A2,1,1)/2,0),"")&","&IFERROR(ROUNDDOWN(MID(A2,3,1)/2,0),"")&","&IFERROR(ROUNDDOWN(MID(A2,5,1)/2,0),"")&","&IFERROR(ROUNDDOWN(MID(A2,7,1)/2,0),"")&","&IFERROR(ROUNDDOWN(MID(A2,9,1)/2,0),"")&","&IFERROR(ROUNDDOWN(MID(A2,11,1)/2,0),"")&","&IFERROR(ROUNDDOWN(MID(A2,13,1)/2,0),"")&","&IFERROR(ROUNDDOWN(MID(A2,15,1)/2,0),""),LEN(A2))
It can be worked with up to 8 number string, as well as odd numbers.
Update
This formula can handle double digit numbers but it supports only from 1 to 4 string numbers(e.g. (25,5,36,48)):
=LEFT(IFERROR(ROUNDDOWN(MID(A2,1,IFERROR(SEARCH(",",A2,1)-1,LEN(A2)))/2,0),"")&","&IFERROR(ROUNDDOWN(MID(A2,SEARCH(",",A2,1)+1,IFERROR(SEARCH(",",A2,SEARCH(",",A2,1)+1)-SEARCH(",",A2,1)-1,LEN(A2)-SEARCH(",",A2,1)))/2,0),"")&","&IFERROR(ROUNDDOWN(MID(A2,SEARCH(",",A2,SEARCH(",",A2,1)+1)+1,IFERROR(SEARCH(",",A2,SEARCH(",",A2,SEARCH(",",A2,1)+1)+1)-SEARCH(",",A2,SEARCH(",",A2,1)+1)-1,LEN(A2)-SEARCH(",",A2,SEARCH(",",A2,1))))/2,0),"")&","&IFERROR(ROUNDDOWN(MID(A2,SEARCH(",",A2,SEARCH(",",A2,SEARCH(",",A2,1)+1)+1)+1,IFERROR(SEARCH(",",A2,SEARCH(",",A2,SEARCH(",",A2,SEARCH(",",A2,1)+1)+1)+1)-SEARCH(",",A2,SEARCH(",",A2,SEARCH(",",A2,1)+1)+1)-1,LEN(A2)-SEARCH(",",A2,SEARCH(",",A2,SEARCH(",",A2,1)+1)+1)))/2,0),""),LEN(A2))

SUM/IF Statement with Text input and a Numeric Sum output in Excel

Ok, I am having trouble with this equation. I have (4) rows for text entries that have a numeric association depending on what you input. The equation I have does not SUM all four rows. With each text input of "I"=100,"P"=86,"N"=63 with a sum dependant on what was input.
=SUM(IF(A4:D4="I",100)+IF(A4:D4="P",86)+IF(A4:D4="N",63,0))
I should have the number 400 in E4 with "I" entered in A4:D4, or 344 in E4 with "P" entered in A4:D4.
Thank you for any help you can give.
KC
You can also do this with an "Array" Formula like so
=SUM((A1:D1="I")*100,(A1:D1="P")*86,(A1:D1="N")*63)
You have to enter this with Ctrl-Shift and Enter, and it will be enclosed in curly brackets.
Look up "Array Formulas" for details, they're a pain to get your head around but will save you a lot of extra columns.
Can take a while to calculate on a large sheet mind.
You can insert values in adjacent cells: (I will transpose the data for simplicity of formatting)
| A | B |
1 | I | =IF(A1="I";100;IF(A1="P";86;IF(A1="N";63;0)))
2 | I | =IF(A1="I";100;IF(A1="P";86;IF(A1="N";63;0)))
3 | I | =IF(A1="I";100;IF(A1="P";86;IF(A1="N";63;0)))
4 | I | =IF(A1="I";100;IF(A1="P";86;IF(A1="N";63;0)))
Then in E4 you have : SUM(A1:A4)

Resources