SUM/IF Statement with Text input and a Numeric Sum output in Excel - 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)

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.

I have a list of keywords and want to count the number of match keywords in each cells text from EXCEL File

I have 2 sheet in a excel file. one is a Dictionary sheet and 2nd is a sheet containing a column of text. I want to match the dictionary keywords columns one by one and then the number of match keywords counts in each cell of the text column.
I have tried these formulas:
=(LEN(B2)-LEN(SUBSTITUTE(B2,Sheet1!A:A,"")))/LEN(Sheet1!A:A)
in this B2 is the first (start) cell of the text column and Sheet1!A:A is the dictionary column of other sheet.
but by this i get zero as a result
=(LEN(B2)-LEN(SUBSTITUTE(B2,Sheet1!A:A,"")))/LEN(Sheet1!A:A)
The result will be like this:
Text number_of_keyword_match | number_of_keyword_match using DIC col 2 | ........
using DIC col 1
1 any Text or sentence/sentences e.g match "3"
2 7
3 0
4 15
5 .................................................
7 .....................................................
.......................................................
..................................continue up to 2815 rows....
Assuming your text input looks like this:
| A |
-+----------------------+
1|apple apple beat beat |
2|apple beat beat carrot|
3|carrot apple apple |
and your dictionary looks like this:
| A | B |
-+-------+-------+
1|apple |beat |
2|beat |carrot |
3| | |
This formula will give you the count per word per cell of text
=(LEN(text!A1)-LEN(SUBSTITUTE(text!A1,dictionary!A1,"")))/LEN(dictionary!A1)
(In this example 2)
If I understand correctly, your expected output would be extra columns in the text sheet where each cell contains the sum of counts of each word in the corresponding column in dictionary, right? For example:
| A | B | C |
-+----------------------+---+---+
1|apple apple beat beat | 4 | 2 |
2|apple beat beat carrot| 3 | 3 |
3|carrot apple apple | 2 | 1 |
You can use array formulas to do this, starting with this one in cell B1:
=SUM(IFERROR((LEN(text!$A1)-LEN(SUBSTITUTE(text!$A1;dictionary!A:A;"")))/LEN(dictionary!A:A);0))
But instead of pressing Enter after pasting it in, press Ctrl+Shift+Enter to run it as an array formula. Then drag this formula down and to the right to get all the counts you want.
I would consider countif(), as an example:
=COUNTIF(Sheet2!A1:A10,Sheet1!A1)
which assumes your list starts in cell A1 on sheet1 and your text in cell a1 on sheet2.
To drag the formula as I showed it, without the data range moving you need :
=COUNTIF(Sheet2!A$1:A$10,Sheet1!A1)
if you put $ before the letters, then the columns don't move.

How to make Excel "IF" formula calculate blank cells as "0"?

How do I make the IF function consider blank cells as "0".
Here is the formula I am using in the H column cells: IF(E1>F1,"YES","NO")
Here is the specific Example:
E | F |G | H |
10 | 0 |30 | YES |
10 | 5 |10 | YES |
10 |-------|-------| NO |
H3 should return "YES" I would think.
In this scenario I cannot change the blank cells to "0", they have to remain blank.
What would be the correct formula for me to use?
I have tried searching around on google and stackoverflow, but the only things I can find are where people are trying to NOT have blanks be considered "0".
=IF(ISBLANK(F1),"YES",IF(E1>F1,"YES","NO")) - Will check for a blank cell, this will work if column F is not formulated
=IF(F1="","YES",IF(E1>F1,"YES","NO")) - Performs a similar check but for the set value "" which is a formulated forced blank cell
=IF(ISNUMBER(F1),IF(E1>F1,"YES","NO"),"YES") - Sense check for if the cell is a number (In case the formulated column is a numerical calculation)
The excel handles automatically for blank cells .
If you enter text it will show error and suggest for correction.
the formaula i use in this examle is
=IF(A1>=B1,"Yes","No")
The result appear as follow

Increment count in column based on value in column

I've 2 columns A and B. A contains names and B contains the count of those names till that record as shown below.
-----------------------------------
| A | B |
-----------------------------------
1 | Fruits | 1 |
2 | Flowers | 1 |
3 | Fruits | 2 |
So, want to have a formula for this. Expecting an array formula. Even if an array formula is not possible, a general formula
Attached a spreadsheet so that it can be explained better.
https://docs.google.com/spreadsheets/d/1wlWqdFwgv90s50iP-bXXBHciyualohj610qFiSatcmQ/edit#gid=1997586177
You do not need an array formula, and I would avoid them when possible. You can accomplish your task with
=COUNTIF(A$1:A1,A1)
Where A1 if the first value in the column of values you want to count. The $ allows you to anchor the top of your COUNTIF range while leaving the bottom dynamic.
In a google spreadsheet you may want to try:
=ArrayFormula(iferror(SORT(ROW(A1:A),SORT(ROW(A1:A),A1:A,1),1)-MATCH(A1:A,SORT(A1:A),0)-ROW()+2))
Example sheet

Excel, sum range split

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)

Resources