I have a column of 1241 values ranging from 1 - 3. What I need to do, for example, is the following:
Check if the cell is equal to 3. If the check is true, check if the associated value 18 columns to the left is equal(OR CONTAINS!) a specific string. I thought something like this:
=COUNTIF(S2:S1242, OFFSET(S2:S1242, 0, -18) = "StringToCheck")
But it did not work. I know how to do this if I were to take a column and check each row individually and then sum the 1241 values, but there has to be a simpler way.
Any suggestions?
Assuming you want to count how many rows meet both criteria, and that you are using Excel 2007 or above:
=COUNTIFS(A1:A7,3,D1:D7,"Hello")
If you are using Excel 2003 or below then it requires an array formula:
=SUM(IF(A1:A7=3,IF(D1:D7="Hello",1,0),0))
use Ctrl-Shift-Enter (rather then just Enter) to complete the formula. This signifies that it is an array-formula.
Related
I am new to excel please help me.
So the situation is we have two contact no column
contact no contact no 1
9864573828 0145883
9834765849 1923832
018294 9876547834
i want to merge two column into 1 having contact no of 10 digit.
contact no
9864573828
9834765849
9876547834
I'm using Excel 2013
In Excel 2013 this formula can be used to list the 10 digit numbers from the first and second range without gaps:
=IFERROR(IFERROR(INDEX(A:A,AGGREGATE(15,6,ROW(A:A)/(LEN(A:A)=10)/(ISNUMBER(--A:A)),ROW(1:1))),INDEX(B:B,AGGREGATE(15,6,ROW(B:B)/(LEN(B:B)=10)/(ISNUMBER(--B:B)),ROW(1:1)-SUMPRODUCT((LEN(A:A)=10)*(ISNUMBER(--A:A)))))),"")
It uses a lot of resources to calculate, so whole column references is highly discouraged. So use actual ranges instead like:
=IFERROR(
IFERROR(
INDEX(A:A,
AGGREGATE(15,6,
ROW($A$2:$A$5)
/(LEN($A$2:$A$5)=10)
/(ISNUMBER(--$A$2:$A$5)),
ROW(1:1))),
INDEX(B:B,
AGGREGATE(15,6,
ROW($B$2:$B$5)
/(LEN($B$2:$B$5)=10)
/(ISNUMBER(--$B$2:$B$5)),
ROW(1:1)
-SUMPRODUCT(
(LEN($A$2:$A$5)=10)
*(ISNUMBER(--$A$2:$A$5)))))),
"")
Note: I think (unable to verify myself) the formula needs entered with ctrl+shift+enter to make it an array formula.
What this formula does is get the first row of the first range where the string length is 10 and the string converted to a number does not produce an error (what would happen in case of text characters in the string).
When you drag down the formula it shows the second found, third, etc... until no values are found in the first range anymore.
In that case the IFERROR makes it look for the same logic in the second range.
As we want it to show the first found value first, we can't reset the ROW(1:1) * - that is used as a counter for the first smallest, second smallest, etc.. - * therefore we use the same counter and use SUMPRODUCT to subtract the total number of strings meeting the conditions in the first range. That way the counter will start at 1 for the second range and starts counting from there.
If no more values are found in the second range it will show a blank value.
So you can drag down the formula up to the first blank result to show each result.
It's probably still slow with actual range references. I highly advise to upgrade to Office 365.
Try the following formula-
=LET(x,TOCOL(A2:B13,1),FILTER(x,LEN(x)=10))
Since your excel version doesn't support TOCOL() and some other formulas you can use this simple solution:
=IF(LEN(A2)=10,A2,IF(LEN(B2)=10,B2,""))
Put it in C2 and drag id down for a result:
Since you didn't specify what to do if both columns has 10 digit number or both doesn't, in those cases it will return first 10 digit number or empty string.
I have array of numbers in a single column like this:
I want only that numbers for which corresponding negative numbers exist. If number exist 2 times, but negative number exist only one time, then I wanted to retain one positive and one negative number. Similarly, if number exists 3 times, and negative number appears only two times, then I want 2 set of numbers including positive and negative. In this case, I wanted to get output:
5 2 -2 -5
Orders of numbers are not relevant for me. Please do not use VBA. You can create multiple column and apply filter at the end.
Thank you for the response, but I wanted to get the data in column next to the values. Like:
5
2
-2
-5
Please help.
Here's another Office 365 solution:
Name the data range DATA
Put this formula anywhere: =CONCAT(REPT(-ROW(A1:A100)&" "&ROW(A1:A100)&" ",COUNTIF(DATA,"="&ROW(A1:A100)*IF(COUNTIF(DATA,"="&-ROW(A1:A100))<COUNTIF(DATA,"="&ROW(A1:A100)),-1,1))))
That will output the pairs into one cell.
Here's a slightly modified Step 2, which excludes duplicates: =CONCAT(IF((COUNTIF(DATA,"="&-ROW(A1:A100))>0)*(COUNTIF(DATA,"="&ROW(A1:A100))>0),-ROW(A1:A100)&" "&ROW(A1:A100)&" ",""))
Looks like this:
The data doesn't need to be sorted. Both methods work up to 100, but you can easily expand that by changing A100 to A1000 or whatever you need.
Use the vlookup formula to identify the rows, and you can use the Filter & Unique formula to get the list, or a pivot table.
First, immediately next to your data use the formula:
=vlookup(A1*-1,$A$1:$A$1,1,0)
For non-365:
This will produce an error for each instance that doesn't have a match. You can filter at this point to get your list from the existing table. You can also create a pivot table under the Data tab of your ribbon and inserting a pivot table. Filter the #N/A from there to get an exclusive list without hidden rows.
For 365:
You can use the following combination of formulas to get the exclusive list as well.
=UNIQUE(FILTER(B1:B8,ISNUMBER(B1:B8)),0,0) or =UNIQUE(FILTER($B$1:$B$8,ISNUMBER($B$1:$B$8)),0,0) should yield the same results
As ScottCraner mentioned, you can circumvent the helper column in 365 by modifying the formula a bit more:
=UNIQUE(FILTER(A1:A8,ISNUMBER(MATCH(-A1:A8,A1:A8,0)),"")
The Match here is doing something similar to the Vlookup, but housing that logic within the formula, so it's a cleaner solution in my opinion.
Using your data the result was { -5,-2,2,5 }
These are spill formulas so you only need to put it in one spot and it will expand the formula over the adjacent cells below where it's entered for however many cells needed to list all the unique numbers that occur. It takes into account the negatives and so on. This may be a 365 formula, so if you're on another version of excel it may not work.
Edit: Adjusted the instructions to fully address the question.
I have cells in my spreadsheet who are like:
RF(4);MN(4);LL(2);TE(4);HA(2)
There is a formula where I can sum all the numbers in that String/Cell?
I can try another way by Office Script, but since he has low speed, and I have to sum a lot of lines of cells with those type of string, i would try to accelerate the process with Excel Formula as much as possible.
best regards
With Excel 2013 and later you can use FILTERXML to pull out the numbers and wrap that in SUMPRODUCT to return the sum:
=SUMPRODUCT(FILTERXML("<t><s>"&SUBSTITUTE(SUBSTITUTE(A1,")","</s><s>"),"(","</s><s>")&"</s></t>","//s[number()=.]"))
One note, this does not work in Excel online or the phone/tablet apps. And some versions of mac also do not have FILTERXML.
If they are always single digit we can use:
=SUMPRODUCT(IFERROR(--MID(A1,SEQUENCE(LEN(A1)),1),0))
or older version:
=SUMPRODUCT(IFERROR(--MID(A1,ROW($ZZ$1:INDEX($ZZ:$ZZ,LEN(A1))),1),0))
For some versions this will require the use of Ctrl-Shift-Enter instead of Enter when exiting edit mode to make it an array formula.
What you want to do is delimit the column based on ";"
Data --> Text to Columns --> Delimit / Next --> Semicolon --> Finish
This will separate the column into 5 columns based on the data you gave, now you'll add 5 additional helper columns that will extract the number.
Assuming your new Data goes from A2:E2 and downward, placing this formula in F2:J2 =SUMPRODUCT(MID(0&A2, LARGE(INDEX(ISNUMBER(--MID(A2, ROW(INDIRECT("1:"&LEN(A2))), 1)) * ROW(INDIRECT("1:"&LEN(A2))), 0), ROW(INDIRECT("1:"&LEN(A2))))+1, 1) * 10^ROW(INDIRECT("1:"&LEN(A2)))/10)
After dragging this formula across the 5 columns (separating the numbers from text); Add 1 last column summing these 5 new columns.
This should be able to handle multiple digits in a single group of parenthesis. You can avoid having all the additional columns, by adding the formula for each column together. I just break this out so if there's issues you have visibility in what's happening and how it works.
I have 12 sheets in one Google Sheets document labeled for each month (January - December). On each sheet column A contains a project number, e.g. "6091".
I'm trying to find a function that will check all of the other sheets to see if there are duplicate cells in the "project number" column of other sheets.
So: "Do any of the cells in column A, match any of the cells in column A on other sheets".
Is there a quick way to do this?
The formula =arrayformula(iferror(match(A2:A, AnotherSheet!A2:A, 0))) checks each value in A2:A of the present sheet for being in A2:A of AnotherSheet. If it's there, it returns the position in AnotherSheet, otherwise the output is empty (the error #N/A is suppressed by iferror).
You can use the above for each of the sheets separately. Alternatively, if you are not interested in the positions and just want to know which entries from A2:A are found elsewhere, then add the results for each sheet:
=arrayformula(iferror(match(A2:A, AnotherSheet!A2:A, 0)) + iferror(match(A2:A, ThirdSheet!A2:A, 0)))
The output is 0 is there is no match, and a nonzero number if there is.
You may try using this to find the number of duplicates:
=counta('JAN'!A:A,'FEB'!A:A)-countA(unique({'JAN'!A:A;'FEB'!A:A})
Where A:A is your column for the data you want to check and the respective files.
This formula counts the total number of data you have, minus the unique data, therefore giving you the total number of duplicates in your dataset.
This formula gives you an overview of the total number of duplicates, however, it doesn't show which cell is a duplicate.
Alternatively, you can add a checker column and input the following formula to check if that specific cell is a duplicate.
=match(cell to check,{range 1;range 2;...range 12})
Alternatively, you may use this formula to find the exact duplicates between the ranges, however this formula does not search within the range itself for duplicates.
=arrayformula(filter(range to check,(countif(arrayformula({Range 1;range 2}),{range to check}))>1))
Personally I think that the last option would be the best as it gives you the exact data to correct.
I am still new to this so hope this helps:)
This formula should work for numerical values:
=COUNT(QUERY({March!A:A;April!A:A},"where Col1="&A2))
If you are searching for text values it would be
=COUNTA(QUERY({March!A:A;April!A:A},"where Col1='"&A2&"'"))
Unfortunately the QUERY function does not work within an arrayformula so you would need to copy the formula down the column. You can add in extra sheets into the { } array as required, separated by a semi-colon
Edit: actually, borrowing from #sandwich, this version should work without the need to copy the formula down the column:
=arrayformula(iferror(match(A2:A,{March!A:A;April!A:A},0)))
I have a data sheet and have to create a report which is based on multiple conditions based on data. Attaching an image of the Data sheet and another sheer which is a report sheet.
Data Sheet:
Report Sheet:
Question: In the report sheet, in column A I have unique types and in column B I want the total count of the objects based on type and color. So presently I want total count of Orange fruit and Orange vegetable. i.e. B3 will have 2 as the value and B4 will be 1.
I tried the following formulae, but I am getting 0 in B3:
=COUNT(IF((Data!$A$2:Data!$A$7=A3 * Data!$B$2:Data!$B$7=“Orange”),Data!$C$2:Data!$C$7))
Is the condition I am using inside IF incorrect?
For getting the total, you are looking for SUM not COUNT.
Especially SUMIFS which as the name suggests, will let you define multiple criterias, like this:
=SUMIFS(C2:C7,A2:A7,"Fruits",B2:B7,"Orange")
This will return 30.
=SUMIFS(C2:C7,A2:A7,"Vegetables",B2:B7,"Orange")
And this will say 14.
So the first argument is the area where the numbers to be summed are;
Next you will add the range where you would like to evaluate the following, the criteria.
Edit
I see that you might want to use COUNTIFS to return the number of occurences, not the total, in this case, this might be very similar:
=COUNTIFS(A2:A7,"Fruits",B2:B7,"Orange")
You can get it to work with your original formula if
(1) You put extra brackets as shown
(2) Use SUM instead of COUNT
(3) Enter it as an array formula using Ctrl-Shift-Enter
=SUM(IF((Data!$A$2:Data!$A$7=A3) * (Data!$B$2:Data!$B$7="Orange"),Data!$C$2:Data!$C$7))
so it appears with curly brackets round it.
I also had to re-type the quotation marks to get it to work.
=SUM((Data!$A$2:Data!$A$7=A3) * (Data!$B$2:Data!$B$7="Orange") * Data!$C$2:Data!$C$7)
is another way of doing it, also as an array formula.