Complicated Conditional Data

default_name

Board Regular
Joined
May 16, 2018
Messages
170
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
  2. MacOS
I am trying to write a function that looks through the data with the following characteristics:
If the range of the data (cells A1:A500) has part number "abc-01" then I want to look at the value for that part (values found in range B1:B500) and see whether the value falls within 4.99 of a referenced cell (F1).

Basically, I am trying to count the frequency of a referenced value for a particular part in a large list of different part numbers.
(Per the security policy on my machine, I cannot use VBA/Macros.)

Not sure my explanation makes sense. Here's the code I have:

Code:
=IF(A1:A500="abc-01",COUNTIFS(B1:B500,">=" &F1-4.99,B1:B500,"<" & F1+4.99),"")

Thanks in advance!
 
Sorry, I had cleared the cell to try and see if there were issues with the cell itself.
=LEN(A16) results in a 0 here

When I put the data back, it results in a 10.
A 10 makes sense here because this part number is 10 digits long.

However, this cell is still being ignored in the COUNTIF function.


The criterion for cells in A1:A500 is abc-01 that has 6 characters, therefore if LEN(A16)=10 it doesn't meet the criterion.

M.
 
Upvote 0

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
I thought the part number had the format AAA-NN where A is an alpha character and N is digit character? Maybe if you posted what your data actually looks like and the actual formula you are using (that you say does not recognize what is in cell A16), we may have a better chance of being able to help you.

The data that I am working with is proprietary information that I am unable to disclose.
I used "abc-01" as an example. Sorry, I didnt think the actual data mattered.

The part numbers have the following format:
########-# or ########-##

Eight numeric digits, one hyphen, and one to two final digits (depending on part number).
 
Last edited:
Upvote 0
The data that I am working with is proprietary information that I am unable to disclose.

The part numbers have the following format:
########-# or ########-##

Eight numeric digits, one hyphen, and one to two final digits (depending on part number).
And the formula you are attempting to use?
 
Upvote 0
Cells A1:A15 are counted as expected.
Cells A17:A51 are counted as expected.
Cell A16 doesnt affect the count at all (even though the exact same part number in A16 is also seen in A3, A17, A26 and several others)

It is as if Excel just skipped over cell A16.
 
Upvote 0
Code:
=COUNTIFS(A1:A500,"abc-01",B1:B500,">=" &F1-4.99,B1:B500,"<" & F1+4.99)

Substitute [abc-01] with the actual part number.
Cells A1:A15 are counted as expected.
Cells A17:A51 are counted as expected.
Cell A16 doesnt affect the count at all (even though the exact same part number in A16 is also seen in A3, A17, A26 and several others)

It is as if Excel just skipped over cell A16.
Okay, so you are using a COUNTIFS function call which means every argument in it must be true in order for the count to register. You have established that A16 contains a properly formatted part number which must mean one of the other two conditions you are testing must be false. So, with that said, what is in cell B16 and what is in cell F16?
 
Upvote 0
The data that I am working with is proprietary information that I am unable to disclose.
I used "abc-01" as an example. Sorry, I didnt think the actual data mattered.

The part numbers have the following format:
########-# or ########-##

Eight numeric digits, one hyphen, and one to two final digits (depending on part number).

Maybe with a wildcard. See if this works - example to count part number = 12345678
=COUNTIFS(A1:A500,"12345678-*",B1:B500,">=" &F1-4.99,B1:B500,"<" & F1+4.99)

or better
=COUNTIFS(A1:A500,C2&"-*",B1:B500,">=" &F1-4.99,B1:B500,"<" & F1+4.99)
where C2 = 12345678

M.
 
Last edited:
Upvote 0
This is getting pretty detailed, and I understand if it has become overly complex without being able to show the actual values.

Here is a scenario I just created to hopefully illustrate what the issue I am having is.
---------------------------

I have the following list of part numbers.
I will be recording the frequency/number of times a certain part number appears and the bin/value of the occurrence.

I am using the following formula to target the number of times Part# 12345678-04 appears:
Code:
=COUNTIFS($A$2:$A$19,"12345678-04",$B$2:$B$19,">=" &C2-4.99,$B$2:$B$19,"<" & C2+4.99)
This code is mimicked with the corresponding C values all the way down column D.

As you can see, all looks well, except the part number that appears at cell A16.
For some reason, cell A16 is being ignored (is not appearing in the Part Frequency list).

Notice how Part# 12345678-04 appears 3 times in Column A.
However, it is only being accounted for 2 times in Column D.
(A value of 1 should appear at Cell D10)

A
B
C
D
1
Part Number
Part Performance
Bin
Part Frequency
2
12345678-01
81
0
0
3
12345678-03

<colgroup><col style="text-align: center;" width="96"></colgroup><tbody>
</tbody>
27
10
0
4
12345678-02

<colgroup><col style="text-align: center;" width="96"></colgroup><tbody>
</tbody>
83
20
1
5
12345678-04

<colgroup><col style="text-align: center;" width="96"></colgroup><tbody>
</tbody>
21
30
0
6
12345678-01

<colgroup><col style="text-align: center;" width="96"></colgroup><tbody>
</tbody>
5
40
0
7
12345678-03

<colgroup><col style="text-align: center;" width="96"></colgroup><tbody>
</tbody>
86
50
0
8
12345678-04

<colgroup><col style="text-align: center;" width="96"></colgroup><tbody>
</tbody>
92
60
0
9
12345678-02

<colgroup><col style="text-align: center;" width="96"></colgroup><tbody>
</tbody>
13
70
0
10
12345678-03

<colgroup><col style="text-align: center;" width="96"></colgroup><tbody>
</tbody>
30
80
0
11
12345678-01

<colgroup><col style="text-align: center;" width="96"></colgroup><tbody>
</tbody>
1
90
1
12
12345678-02

<colgroup><col style="text-align: center;" width="96"></colgroup><tbody>
</tbody>
53
100
0
13
12345678-03

<colgroup><col style="text-align: center;" width="96"></colgroup><tbody>
</tbody>
81
14
12345678-01

<colgroup><col style="text-align: center;" width="96"></colgroup><tbody>
</tbody>
94
15
12345678-02

<colgroup><col style="text-align: center;" width="96"></colgroup><tbody>
</tbody>
58
16
12345678-04

<colgroup><col style="text-align: center;" width="96"></colgroup><tbody>
</tbody>
80
17
12345678-01

<colgroup><col style="text-align: center;" width="96"></colgroup><tbody>
</tbody>
73
18
12345678-02

<colgroup><col style="text-align: center;" width="96"></colgroup><tbody>
</tbody>
31
19
12345678-03

<colgroup><col style="text-align: center;" width="96"></colgroup><tbody>
</tbody>
66

<tbody>
</tbody>
 
Upvote 0
The formula worked for me


A
B
C
D
1
Part Number​
Part Performance​
Bin​
Part Frequency​
2
12345678-01​
81​
0​
0​
3
12345678-03​
27​
10​
0​
4
12345678-02​
83​
20​
1​
5
12345678-04​
21​
30​
0​
6
12345678-01​
5​
40​
0​
7
12345678-03​
86​
50​
0​
8
12345678-04​
92​
60​
0​
9
12345678-02​
13​
70​
0​
10
12345678-03​
30​
80​
1​
11
12345678-01​
1​
90​
1​
12
12345678-02​
53​
100​
0​
13
12345678-03​
81​
14
12345678-01​
94​
15
12345678-02​
58​
16
12345678-04​
80​
17
12345678-01​
73​
18
12345678-02​
31​
19
12345678-03​
66​

<tbody>
</tbody>


D2 copied down
=COUNTIFS($A$2:$A$19,"12345678-04",$B$2:$B$19,">=" &C2-4.99,$B$2:$B$19,"<" & C2+4.99)

M.
 
Upvote 0
This is where my issue is. The cell should be evaluating, but it isn’t for some reason.

No matter what I put on A16, whether it be “cat” or even a string of numbers (with the corresponding COUNTIFS update statement), the function is not reading the cell.

My question here is why. I have tried clearing all formatting on the cell. I have tried deleting the cell entirely and inserting a blank one. I can’t seem to pinpoint WHY this cell is being overlooked. I don’t see any other references to the cell in the workbook except here.
 
Upvote 0

Forum statistics

Threads
1,214,787
Messages
6,121,561
Members
449,038
Latest member
Guest1337

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top