Comparison of strings containing inequalities in excel countif() function
up vote
1
down vote
favorite
I'm analyzing some survey data in which the responses are in the form of a string containing inequalities, e.g.
a) < 5
b) 5-10
c) 11-15
d) > 15
I'm attempting to tabulate responses using the Countifs
function, and Excel does not appear to parse the value of the cell with the criteria argument as a string, and so returns 'False' for those bins; it does not evaluate a cell containing the string '< 5' as being equal to another cell containing '< 5', or the literal argument "< 5".
A comparison of the reference cells in other formulas, using =
or EXACT()
returns TRUE
.
I know the criteria argument of the conditional operators like COUNTIF()
, SUMIF()
, etc. use strings with inequalities when they're actually serving as operators, but I can't figure out how to suppress this and evaluate these cells as simple strings. Thanks so much!
microsoft-excel worksheet-function
add a comment |
up vote
1
down vote
favorite
I'm analyzing some survey data in which the responses are in the form of a string containing inequalities, e.g.
a) < 5
b) 5-10
c) 11-15
d) > 15
I'm attempting to tabulate responses using the Countifs
function, and Excel does not appear to parse the value of the cell with the criteria argument as a string, and so returns 'False' for those bins; it does not evaluate a cell containing the string '< 5' as being equal to another cell containing '< 5', or the literal argument "< 5".
A comparison of the reference cells in other formulas, using =
or EXACT()
returns TRUE
.
I know the criteria argument of the conditional operators like COUNTIF()
, SUMIF()
, etc. use strings with inequalities when they're actually serving as operators, but I can't figure out how to suppress this and evaluate these cells as simple strings. Thanks so much!
microsoft-excel worksheet-function
Does anything here help? superuser.com/questions/1132899/…
– Rey Juna
Dec 7 at 22:52
Better share some sample data with us to create proper solution!!
– Rajesh S
Dec 8 at 5:37
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I'm analyzing some survey data in which the responses are in the form of a string containing inequalities, e.g.
a) < 5
b) 5-10
c) 11-15
d) > 15
I'm attempting to tabulate responses using the Countifs
function, and Excel does not appear to parse the value of the cell with the criteria argument as a string, and so returns 'False' for those bins; it does not evaluate a cell containing the string '< 5' as being equal to another cell containing '< 5', or the literal argument "< 5".
A comparison of the reference cells in other formulas, using =
or EXACT()
returns TRUE
.
I know the criteria argument of the conditional operators like COUNTIF()
, SUMIF()
, etc. use strings with inequalities when they're actually serving as operators, but I can't figure out how to suppress this and evaluate these cells as simple strings. Thanks so much!
microsoft-excel worksheet-function
I'm analyzing some survey data in which the responses are in the form of a string containing inequalities, e.g.
a) < 5
b) 5-10
c) 11-15
d) > 15
I'm attempting to tabulate responses using the Countifs
function, and Excel does not appear to parse the value of the cell with the criteria argument as a string, and so returns 'False' for those bins; it does not evaluate a cell containing the string '< 5' as being equal to another cell containing '< 5', or the literal argument "< 5".
A comparison of the reference cells in other formulas, using =
or EXACT()
returns TRUE
.
I know the criteria argument of the conditional operators like COUNTIF()
, SUMIF()
, etc. use strings with inequalities when they're actually serving as operators, but I can't figure out how to suppress this and evaluate these cells as simple strings. Thanks so much!
microsoft-excel worksheet-function
microsoft-excel worksheet-function
edited Dec 7 at 23:27
Twisty Impersonator
17.6k136395
17.6k136395
asked Dec 7 at 22:17
William Richter
82
82
Does anything here help? superuser.com/questions/1132899/…
– Rey Juna
Dec 7 at 22:52
Better share some sample data with us to create proper solution!!
– Rajesh S
Dec 8 at 5:37
add a comment |
Does anything here help? superuser.com/questions/1132899/…
– Rey Juna
Dec 7 at 22:52
Better share some sample data with us to create proper solution!!
– Rajesh S
Dec 8 at 5:37
Does anything here help? superuser.com/questions/1132899/…
– Rey Juna
Dec 7 at 22:52
Does anything here help? superuser.com/questions/1132899/…
– Rey Juna
Dec 7 at 22:52
Better share some sample data with us to create proper solution!!
– Rajesh S
Dec 8 at 5:37
Better share some sample data with us to create proper solution!!
– Rajesh S
Dec 8 at 5:37
add a comment |
2 Answers
2
active
oldest
votes
up vote
1
down vote
accepted
As stated The countifs in the criteria accepts string and thus <5
is reading less than five not the string.
To get it to look at the string use "="
=COUNTIF(C2,"="&C3)
By adding the =
before the <
, Excel sees it as a string and not an operand.
add a comment |
up vote
0
down vote
Instead of fighting the bugs of Excel and getting it to recognize the <
symbol, I'd solve the problem by removing it altogether. Just replace <5
with something like 5_or_less
and then COUNTIF
should work.
=SUBSTITUTE(A1,"<5","5_or_less")
will do the replacement for A1
and <5
. You can put this in a new column, say B1
. Then do another replacement for >15
in C1
like =SUBSTITUTE(B1,">15","15_or_more"). Then run
COUNTIFon column
C`.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1381776%2fcomparison-of-strings-containing-inequalities-in-excel-countif-function%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
As stated The countifs in the criteria accepts string and thus <5
is reading less than five not the string.
To get it to look at the string use "="
=COUNTIF(C2,"="&C3)
By adding the =
before the <
, Excel sees it as a string and not an operand.
add a comment |
up vote
1
down vote
accepted
As stated The countifs in the criteria accepts string and thus <5
is reading less than five not the string.
To get it to look at the string use "="
=COUNTIF(C2,"="&C3)
By adding the =
before the <
, Excel sees it as a string and not an operand.
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
As stated The countifs in the criteria accepts string and thus <5
is reading less than five not the string.
To get it to look at the string use "="
=COUNTIF(C2,"="&C3)
By adding the =
before the <
, Excel sees it as a string and not an operand.
As stated The countifs in the criteria accepts string and thus <5
is reading less than five not the string.
To get it to look at the string use "="
=COUNTIF(C2,"="&C3)
By adding the =
before the <
, Excel sees it as a string and not an operand.
answered Dec 8 at 0:21
Scott Craner
10.9k1814
10.9k1814
add a comment |
add a comment |
up vote
0
down vote
Instead of fighting the bugs of Excel and getting it to recognize the <
symbol, I'd solve the problem by removing it altogether. Just replace <5
with something like 5_or_less
and then COUNTIF
should work.
=SUBSTITUTE(A1,"<5","5_or_less")
will do the replacement for A1
and <5
. You can put this in a new column, say B1
. Then do another replacement for >15
in C1
like =SUBSTITUTE(B1,">15","15_or_more"). Then run
COUNTIFon column
C`.
add a comment |
up vote
0
down vote
Instead of fighting the bugs of Excel and getting it to recognize the <
symbol, I'd solve the problem by removing it altogether. Just replace <5
with something like 5_or_less
and then COUNTIF
should work.
=SUBSTITUTE(A1,"<5","5_or_less")
will do the replacement for A1
and <5
. You can put this in a new column, say B1
. Then do another replacement for >15
in C1
like =SUBSTITUTE(B1,">15","15_or_more"). Then run
COUNTIFon column
C`.
add a comment |
up vote
0
down vote
up vote
0
down vote
Instead of fighting the bugs of Excel and getting it to recognize the <
symbol, I'd solve the problem by removing it altogether. Just replace <5
with something like 5_or_less
and then COUNTIF
should work.
=SUBSTITUTE(A1,"<5","5_or_less")
will do the replacement for A1
and <5
. You can put this in a new column, say B1
. Then do another replacement for >15
in C1
like =SUBSTITUTE(B1,">15","15_or_more"). Then run
COUNTIFon column
C`.
Instead of fighting the bugs of Excel and getting it to recognize the <
symbol, I'd solve the problem by removing it altogether. Just replace <5
with something like 5_or_less
and then COUNTIF
should work.
=SUBSTITUTE(A1,"<5","5_or_less")
will do the replacement for A1
and <5
. You can put this in a new column, say B1
. Then do another replacement for >15
in C1
like =SUBSTITUTE(B1,">15","15_or_more"). Then run
COUNTIFon column
C`.
answered Dec 7 at 23:59
Docconat
83
83
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1381776%2fcomparison-of-strings-containing-inequalities-in-excel-countif-function%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Does anything here help? superuser.com/questions/1132899/…
– Rey Juna
Dec 7 at 22:52
Better share some sample data with us to create proper solution!!
– Rajesh S
Dec 8 at 5:37