OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

USING COUNTIF

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Calc
View previous topic :: View next topic  
Author Message
JERRYC
General User
General User


Joined: 26 Jun 2011
Posts: 8

PostPosted: Sun Jun 26, 2011 10:38 am    Post subject: USING COUNTIF Reply with quote

ENTER 6 IN B9
ENTER 5 IN B10
ENTER 4 IN B11
ENTER 3 IN B12

FORMULA:
=COUNTIF(B12;"<B9")+COUNTIF(B12;"<B10")+COUNTIF(B12;"<B11")
THE RESULT IS "0" SHOULD NOT IT BE "3"
Back to top
View user's profile Send private message
Ed
Super User
Super User


Joined: 28 May 2003
Posts: 1040

PostPosted: Sun Jun 26, 2011 11:21 am    Post subject: Reply with quote

Why use COUNTIF with a range of only one cell?

It would more logical to use a simple IF:

Code:
=IF(B12<B9;1;0)+IF(B12<B10;1;0)+IF(B12<B11;1;0)


You could even use the way TRUE is interpreted as 1 and FALSE is interpreted as 0 when added together, and use the formula:

Code:
=(B12<B9)+(B12<B10)+(B12<B11)
Back to top
View user's profile Send private message
Villeroy
Super User
Super User


Joined: 04 Oct 2004
Posts: 10065
Location: Germany

PostPosted: Sun Jun 26, 2011 11:33 am    Post subject: Reply with quote

Countif is a little bit silly in this context.
Anyhow, you can compare with an operator and a value in one string:
=COUNTIF(B12;"<6")+COUNTIF(B12;"<5")+COUNTIF(B12;"<4")

or concatenate an operator string with a reference:
=COUNTIF(B12;"<"&B9)+COUNTIF(B12;"<"&B10)+COUNTIF(B12;"<"&B11)
_________________
Rest in peace, oooforum.org
Get help on http://forum.openoffice.org
Back to top
View user's profile Send private message
JERRYC
General User
General User


Joined: 26 Jun 2011
Posts: 8

PostPosted: Sun Jun 26, 2011 11:36 am    Post subject: Reply with quote

Being new to the game, I really appreciate your help. Thanks alot
Back to top
View user's profile Send private message
karolus
OOo Advocate
OOo Advocate


Joined: 22 Jun 2011
Posts: 208

PostPosted: Sun Jun 26, 2011 12:15 pm    Post subject: Reply with quote

Hi
The Job is done by:
Code:
=COUNTIF(B9:B11;">"&B12)


@villeroy
COUNTIF isn't silly in that Context!

Karolus
Back to top
View user's profile Send private message
Ed
Super User
Super User


Joined: 28 May 2003
Posts: 1040

PostPosted: Sun Jun 26, 2011 1:05 pm    Post subject: Reply with quote

karolus wrote:
Code:
=COUNTIF(B9:B11;">"&B12)


@villeroy
COUNTIF isn't silly in that Context!


Maybe not in that formula, but using COUNTIF as JERRYC did with only a single cell in the range is silly!
Back to top
View user's profile Send private message
JERRYC
General User
General User


Joined: 26 Jun 2011
Posts: 8

PostPosted: Mon Jun 27, 2011 5:56 am    Post subject: Assigning a value to what if Reply with quote

enter 5 in A1
enter 5 in A2
enter 4 in A3
enter 3 in A4

enter 5 in B1
enter 5 in B2
enter 5 in B3
enter 5 in B4

enter 5 in C1
enter 5 in C2
enter 6 in C3
enter 7 in C4

1. What I want is to find the smallest number in (A1:A4) and assign a 2 in a different cell
2. same as 1, but if the smallest number is more than once assign each one a 1
Do the same for (B1:B4) and (C1:C4)


Last edited by JERRYC on Mon Jun 27, 2011 7:05 am; edited 1 time in total
Back to top
View user's profile Send private message
karolus
OOo Advocate
OOo Advocate


Joined: 22 Jun 2011
Posts: 208

PostPosted: Mon Jun 27, 2011 6:28 am    Post subject: Reply with quote

Hi
With Calc-formulas you cannot assign values to *other* cells, you have to do it with Makrocode ( Basic , Python, etc. )

Karolus
Back to top
View user's profile Send private message
JERRYC
General User
General User


Joined: 26 Jun 2011
Posts: 8

PostPosted: Mon Jun 27, 2011 6:42 am    Post subject: Reply with quote

karolus wrote:
Hi
With Calc-formulas you cannot assign values to *other* cells, you have to do it with Makrocode ( Basic , Python, etc. )

Karolus

I would like to assign it to a different cell
Back to top
View user's profile Send private message
Ed
Super User
Super User


Joined: 28 May 2003
Posts: 1040

PostPosted: Mon Jun 27, 2011 6:57 am    Post subject: Re: Assigning a value to what if Reply with quote

JERRYC wrote:
1. What I want is to find the smallest number in (A1:A4) and assign it a 2
2. same as 1, but if the smallest number is more than once assign each one a 1
Do the same for (B1:B4) and (C1:C4)

Formulae can not change the contents of cells. All a formula can do is perform a calculation, and the result of that calculation becomes the value of the cell containing the formula.
Back to top
View user's profile Send private message
JERRYC
General User
General User


Joined: 26 Jun 2011
Posts: 8

PostPosted: Mon Jun 27, 2011 7:06 am    Post subject: Re: Assigning a value to what if Reply with quote

Ed wrote:
JERRYC wrote:
1. What I want is to find the smallest number in (A1:A4) and assign it a 2
2. same as 1, but if the smallest number is more than once assign each one a 1
Do the same for (B1:B4) and (C1:C4)

Formulae can not change the contents of cells. All a formula can do is perform a calculation, and the result of that calculation becomes the value of the cell containing the formula.


I would like it to assign the value in a different cell
Back to top
View user's profile Send private message
Ed
Super User
Super User


Joined: 28 May 2003
Posts: 1040

PostPosted: Mon Jun 27, 2011 7:29 am    Post subject: Re: Assigning a value to what if Reply with quote

JERRYC wrote:
Ed wrote:
JERRYC wrote:
1. What I want is to find the smallest number in (A1:A4) and assign it a 2
2. same as 1, but if the smallest number is more than once assign each one a 1
Do the same for (B1:B4) and (C1:C4)

Formulae can not change the contents of cells. All a formula can do is perform a calculation, and the result of that calculation becomes the value of the cell containing the formula.


I would like it to assign the value in a different cell


As has already been said, spreadsheet formulae can not assign values to other cells. Repeating that you want to do something impossible does not magically make it possible.
Back to top
View user's profile Send private message
JERRYC
General User
General User


Joined: 26 Jun 2011
Posts: 8

PostPosted: Mon Jun 27, 2011 7:38 am    Post subject: Re: Assigning a value to what if Reply with quote

Ed wrote:
JERRYC wrote:
Ed wrote:
JERRYC wrote:
1. What I want is to find the smallest number in (A1:A4) and assign it a 2
2. same as 1, but if the smallest number is more than once assign each one a 1
Do the same for (B1:B4) and (C1:C4)

Formulae can not change the contents of cells. All a formula can do is perform a calculation, and the result of that calculation becomes the value of the cell containing the formula.


I would like it to assign the value in a different cell


As has already been said, spreadsheet formulae can not assign values to other cells. Repeating that you want to do something impossible does not magically make it possible.


"Formulae can not change the contents of cells. All a formula can do is perform a calculation, and the result of that calculation becomes the value of the cell containing the formula.[/quote] This is what I want, putting a formula in a different cell to get the result"
Back to top
View user's profile Send private message
Ed
Super User
Super User


Joined: 28 May 2003
Posts: 1040

PostPosted: Mon Jun 27, 2011 7:59 am    Post subject: Reply with quote

What result are you trying to get? It is really not at all clear what you are trying to do.
Back to top
View user's profile Send private message
JERRYC
General User
General User


Joined: 26 Jun 2011
Posts: 8

PostPosted: Mon Jun 27, 2011 8:02 am    Post subject: Reply with quote

Ed wrote:
What result are you trying to get? It is really not at all clear what you are trying to do.


Well, if I don't know what I want you surely can't help, thanks any way.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Calc All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group