COUNTIFS with 2 different ranges and conditions - excel

I have a table from which I need to count the ammount of specific numbers.
The table is dynamic and can have between 1 to 25 columns where the numbers are and then a code that starts with either a letter, 1 or 2. It has multiple rows too.
What I need is to have formulas to count the ammount of each specific number range if the code starts with the correct character as shown in the example image:
I can't manage to join the condition of the first range being between 2 numbers and the second range starting with a specific character.
The formula should look somewhat like this (count numbers between 200 and 299 with the code starting with 2):
=COUNTIFS(Table[[1]:[4]];">=200";Table[[1]:[4]];"<=299";Table[code];"2*")
letter 1 2 letter 1 2
100-199 200-299 200-299 2 1 1
300-399 400-499 400-499 3 3 3
500-599 600-699 2 2
700-799 2
1 2 3 4 code
139 307 165 B01
430 2CTE
581 703 PDC
312 354 528 746 GVM7
600 477 1OMC
299 425 413 2LP
231 666 420 433 1MLTQ

put this in F3 then copy over and down:
=IFERROR(SUMPRODUCT((Table[[1]:[4]]>=--LEFT(B3,3))*(Table[[1]:[4]]<=--RIGHT(B3,3))*(((ISNUMBER(F$2))*(LEFT(Table[[code]:[code]])=F$2&""))+((NOT(ISNUMBER(F$2)))*(NOT(ISNUMBER(LEFT(Table[[code]:[code]]))))))),"")
As per your comments to get everything between 400 and 499 and starts with 2:
=SUMPRODUCT((Table[[1]:[4]]>=400)*(Table[[1]:[4]]<=499)*(LEFT(Table[[code]:[code]])="2"))

Related

How do I reformat a column of numeric data to have five rows between specific values when these specific values are spaced differently daily?

example: * (loading bays are door assignments in a warehouse) in this column of data, Loading bay M1-1 has 3 rows until next loading bay value of 152, continuing downward from bay 152 to 151, there are 3 rows, same to bay 150, however from bay 150 to bay 149, there are 4 rows. I need to keep these bay numbers exactly 5 rows apart; (pattern being - BAY, 4 rows of data, BAY, 4 rows of data, BAY etc...) by inserting a blank row IF the next bay is LESS THAN 5 rows from the next bay.
I have a properly formatted template of each bay#, then 4 rows, then the next bay#
M1-1
5
0.00%
7
152
164
0.69%
38
151
0
0.00%
0
150
870
3.65%
17
136
149
2,438
10.22%
34
350
>>>>
correctly formatted column I created with index and match: How do I retrieve the 3 rows of data below the constantly changing row spacing and copy into my correctly formatted column.
M1-1
0
0
0
0
152
0
0
151
0
0
0
150
0
0
149
0
0
0
148
My question and problem can seemingly be solved by inserting a row based on EACH bay# and how many rows until the next door. This needs to be fluid as the values change daily sometimes 3 spaces, sometimes 4. My result MUST be 4 rows then the next bay.
Not sure if I am asking correctly and will greatly appreciate ANY recommendations.
I am by no means an Excel expert, I solve problems often in odd ways and this I just have not been successful.

how to change cells color per value next to it

I have the following set of 2 columns and n rows:
A B
1 44000 44000
2 2800 2730
3 17000 21160
4 1000 1046
5 700 0
6 1500 1249
7 300 107
8 1200 400
9 0 1400
10 4500 3582
11 0 280
I would like to create a Conditional Formatting rule for column B, so if value in any row exceeds the associated value in row A the cell becomes red: https://gyazo.com/83a45768c6952f5590448700059179ce
The problem with this approach is I have to modify every single cell and cannot apply the whole Rule for all cells in column B.
If I apply this rule to the set of cells in col A I receive: This type of reference cannot be used in Conditional Formatting formula: http://prntscr.com/feo3c0
The formula:
=$B1>$A1
The Applies to:
=$B:$B

Excel Rank Multiple Columns

I'm facing a issue with ranking in Excel particularly in regards to tie breaking. I tried several options but i guess they don't fit my issue. Its quite simple really, I'll explain:
The Data:
1 2 3 4 5 6 7 8 9 10
87 83 74 95 69 90 73 0 74 85
121 121 96 121 121 121 121 83 121 121
As you can see its easy for me to rank the first line (I'm working in columns instead of rows for the data). When i do a Rank Function gives the following result:
3 5 6 1 9 2 8 10 6 4
Which is correct.
The problem arises in the second line. There are ties because all of them reach the maximum of 121:
1 1 9 1 1 1 1 10 1 1
What i would like to do is take the first row as a tie breaker. So even if there is a tie the first line which was firstly text but now is a sequence from 1 to 10 could provide as secondary criteria to order the rank, thus giving the following ranking line:
1 2 9 3 4 5 6 10 7 9
Could one achieve this result?
Thank You very much in advance.
You need a helper row to break the tie. You can add a fraction of the first row to the second row to create a new row & use the new row to rank
A4 = A3+(A2/(MAX($A$2:$J$2)+1))
Using the MAX I ensure the fraction is less than 1 which is adequate to break ties in this case.
A6 = RANK(A4,$A$4:$J$4)
You can hide the helper row if you dont want to show it.

excel formula for same data but highest number

I need to know the formula for my data like this :
A B C
234 5
234 4
234 2
255 6
255 3
266 2
266 1
I want to mark same column C with 1 to those having same number in A but highest number in B. thank you.
I think this is what you are looking for
find max min value based on criteria

How to use COUNTX to find number of occurences of variable

This question pertains to PowerPivot.
I am currently designing an invoices table to include a column called "Hits", which counts the amount of times a single customer has purchased one item.
I currently have a table like so:
INVOICES
INVOICE ID CUSTOMER ID PRODUCT ID
321 1 444
322 2 411
323 3 221
324 4 321
325 5 444
326 5 444
This is what I would like it do look like:
INVOICES
INVOICE ID CUSTOMER ID PRODUCT ID HITS
321 1 444 1
322 2 411 1
323 3 221 1
324 4 321 1
325 5 444 2
326 5 444 2
As you can see, the row "hits" calculates how many times that particular customer has ordered that particular product.
Thanks for any help!
Assuming data in columns A, B and C try this formula in D2 copied down
=COUNTIFS(B:B,B2,C:C,C2)
That gives you exactly what you want - a count of rows where customer and product both match the current row

Resources