Count number of rows with conditions met in multiple columns - excel

I can use
=COUNTIFS(range1, criteria1, range2, criteria2…) + COUNTIFS(...) etc
Count number of rows with conditions met in two columns
My data is such that the above will require needing approximately 150+ instances of countifs just for one cell. And I need to do this for 10K or so cells.
So wondering if there is another function/way to do this in a more efficient manner? Example of data as follows;
1 2 10 6
2 3 9 4
3 4 8 5
7 6 7 2
4 5 1 6
2 1 6 7
5 6 2 8
2 5 3 10
6 7 2 10
And need to count how many times number 2 & 6 occur on the same row.
EDIT: I also need to do this with any number combination. ie 2&6, 1&6, 5&10 etc.
Thanks

Add a column with a serial no from 1 to n.
Then use a nested if:
SUM(IF(SERIAL_NO = SERIAL NO
IF( IF COLUMN1 =2 AND COLUMN 3 = 6,10))) AS 26

Related

How to multiple column join in one column in excel (I Want Formula)

HOW TO JOIN MULTIPLE COLUMN IN ONE COLUMN
TABLE 1 TABLE 2 TABLE 3
1 2 5
2 4 3
3 5 3
4 5 1
I WANT TO
1
2
3
4
2
4
5
5
5
3
3
1
If your data is like below, enter the formula in the first row of any column and drag down until there is no value left over,
=IF(ROW()<=COUNTA(A:A),INDEX(A:A,ROW()),IF(ROW()<=COUNTA(A:B),INDEX(B:B,ROW()-COUNTA(A:A)),IF(ROW()>COUNTA(A:C),"",INDEX(C:C,ROW()-COUNTA(A:B)))))

How to Number Rows Every 1000

How can I autonumber for every 1000 rows? without using macros.
I am trying to divide/batch 100k records for every 1000. And i figured creating batches and autonumbering them is a start.
Row1
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
2 1
2 2
2 3
2 4
2 5
2 6
2 7
2 8
3 1
3 2
3 3
3 4
3 5
3 6
3 7
3 8
In A1 enter:
=ROUNDUP(ROW()/8,0)
and copy down. In B1 enter:
=MOD(ROW()-1,8)+1
and copy down:
You type the first and second rows as 1 and 2 and then highlighting them and dragging from the little square at the bottom right of the selection will autofill with sequential numbers (ie 1, 2, 3, 4). Once you get to 1000 you can copy and paste the whole column up to that point at the bottom. Pasting 99 times should provide you with what you are requesting. Cheers.
MOD(dividend, divisor)
https://support.google.com/docs/table/25273?hl=en
Use that function with 1000 as the divisor. That should work

how find unique value from Different column

A B ANSWER
1 1 1
3 3 3
1 2 1
2 4 2
4 4 4
5 5 5
6 6 6
i have used this function to get above answer "=IF(ISERROR(MATCH(A2:A8,$B$1:$B$8,0)),"",A2)"
but I need answer like this i have given below (suppose if you take value in A column "1"
Which is repeated only once in column B)
A B ANR
1 1 1
3 3 3
1 2 0
2 4 2
4 4 4
5 5 5
6 6 6
I've just wrapped your formula in a condition that returns 0 where the count of the A value from start to the current row is more than one:
=IF(COUNTIF(A$1:A2,A2)>1,0,IF(ISERROR(MATCH(A2:A8,$B$1:$B$8,0)),"",A2))
.
An alternative formula that gives the same results as above for the sample data provided but may (or may not) suit the additional requirements mentioned in a comment:
=IF(COUNTIF(A$2:A$10,A2)<=COUNTIF(B$2:B$10,A2),A2,IF(COUNTIF(A$2:A2,A2)>COUNTIF(B$2:B$10,A2),0,IF(COUNTIF(A$2:A$10,A2)>COUNTIF(B$2:B2,A2),A2,0)))

Dynamically determining range to apply formula/function in EXCEL

I need to determine the range to apply the Frequency function. Here's what the problem is. On the given sheet, I have subtotals for my data and there is a column which has "Stop" Values.
The data would look something like:
Route1
Order# Stop# Qty
001016 1 5
008912 1 5
062232 2 6
062232 3 2
069930 4 1
1000 4 3
1001 4 4
1001 5 8
1003 8 1
Route 1 Subtotal 6 35
Route2
Order# Stop# Qty
10065 1 5
10076 1 5
10077 2 6
10079 3 2
10087 4 1
10098 4 3
10109 4 4
10171 5 8
10175 8 1
Route 2 Subtotal 6 35
How do I write VBA code for calculating the distinct stop values. I need the distinct count of the stop#. Hence in the example above you can see that the total stops are 6 because 1 stop can have multiple orders and 1 route can have multiple orders/stop. Hope I am making sense here. Let me know how I would write my VBA code for this. Thanks for your help.
For the Stop Subtotal unique count, try this formula (adjust ranges as required):
=COUNT(1/FREQUENCY(B2:B10,B2:B10))

Giving duplicates in Excel a unique identifier

I have a large excel spreadsheet containing multiple address lines. Many of these adress lines contain duplicate postcodes, with differing steet adrresses.
I need to seperate out each of these duplicates onto different spreadhseets, so that no one spreadhseet contains the same postcode. I'm currently using an =if() statement to identify the duplicates, then cutting and poasting, and repeating almost ad infinitum to speperate them all out
as an example:
address 1 postcode 1
address 2 postcode 1
address 3 postcode 1
address 4 postcode 2
address 5 postcode 2
address 6 postcode 3
address 7 postcode 3
address 8 postcode 3
address 9 postcode 3
would give 4 spreadsheets:
1)
address 1 postcode 1
address 4 postcode 2
address 6 postcode 3
2)
address 2 postcode 1
address 5 postcode 2
address 7 postcode 3
etc
Any hints on a vb script?
Many thanks
Nick
If this is a one-off thing, then I'd consider doing it in the worksheet and bulk cut-pasting. I'd try something like this:
Sort my data on the post code column
In a new column, add a function to count the number of post codes below the current row that are duplicates of the code on that row (see below)
Save (copy/paste-special-values) the values obtained
Sort by duplicate number
Cut and paste blocks by duplicate number to new sheets
Say I have 20 values between 1 and 5 in column G. I put the following formula in H1:
=SUM(IF(G1:$G$20=G1,1,0))
... and (important bit) enter it as an array formula using Control+Shift+Enter. Now I copy that formula down (for speed, double-click the "fill handle" on the bottom right-hand corner of the cell). Here's my result:
1 2
1 1
2 2
2 1
3 8
3 7
3 6
3 5
3 4
3 3
3 2
3 1
4 2
4 1
5 6
5 5
5 4
5 3
5 2
5 1
Now I can copy column H and Edit...Paste Special...Values to fix the values. Sort by H to get this:
1 1
2 1
3 1
4 1
5 1
1 2
2 2
3 2
4 2
5 2
3 3
5 3
3 4
5 4
3 5
5 5
3 6
5 6
3 7
3 8
Now I have sets of records to copy to each of the 8 sheets that I now know are needed.
Of course, if you're going to be doing this a lot, then a macro would be useful. It needn't be much more complex than automating the above.

Resources