Calc Function

classic Classic list List threaded Threaded
4 messages Options
James E. Lang James E. Lang
Reply | Threaded
Open this post in threaded view
|

Calc Function

Please fill in the blank ("___") below with a function name or tell me there is no such function:

SUM(range) is to SUMIF(range1,criteria,range2) as COUNT(range) is to ___(range1,criteria,range2)

COUNTIF would seem to be the logical answer but I don't think it supports the third parameter and thus it is not analogous to COUNT.

I'm wanting to use it as follows:

=IF(___(A$3:A7,A7,Q$3:Q7)=___(A$3:A7,A7,R$3:R7),SUM(A$3:A7,A7,R$3:R7)-SUM(A$3:A7,A7,Q$3:Q7),"Error 4")

Where Error 4 means that the start miles in Q$3:Q7 and end miles in R$3:R7 are not properly paired and thus the miles driven on date A7 cannot be determined.

I realize that I can add two columns (e.g. AA and AB) such that the content of their cells (AA$3:AA7 and AB$3:AB7) is 1 if the corresponding cell in column Q or R respectively contains a number (otherwise it's a zero length string). Then I could use SUMIF(…,AA$3:AA7)=SUMIF(…,AB$3:AB7) as the condition within the IF(condition,true,false) construct in my formula.

--
Jim


--
To unsubscribe e-mail to: [hidden email]
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted
Gerald Pechoc Gerald Pechoc
Reply | Threaded
Open this post in threaded view
|

Re: Calc Function

In LO 4.1 the COUNTIF Function has only two params: range and criteria.

Gerald

On 2014-01-11 19:17, James E Lang wrote:

> Please fill in the blank ("___") below with a function name or tell me there is no such function:
>
> SUM(range) is to SUMIF(range1,criteria,range2) as COUNT(range) is to ___(range1,criteria,range2)
>
> COUNTIF would seem to be the logical answer but I don't think it supports the third parameter and thus it is not analogous to COUNT.
>
> I'm wanting to use it as follows:
>
> =IF(___(A$3:A7,A7,Q$3:Q7)=___(A$3:A7,A7,R$3:R7),SUM(A$3:A7,A7,R$3:R7)-SUM(A$3:A7,A7,Q$3:Q7),"Error 4")
>
> Where Error 4 means that the start miles in Q$3:Q7 and end miles in R$3:R7 are not properly paired and thus the miles driven on date A7 cannot be determined.
>
> I realize that I can add two columns (e.g. AA and AB) such that the content of their cells (AA$3:AA7 and AB$3:AB7) is 1 if the corresponding cell in column Q or R respectively contains a number (otherwise it's a zero length string). Then I could use SUMIF(…,AA$3:AA7)=SUMIF(…,AB$3:AB7) as the condition within the IF(condition,true,false) construct in my formula.
>

--
To unsubscribe e-mail to: [hidden email]
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted
Jack Jack
Reply | Threaded
Open this post in threaded view
|

Re: Calc Function

In reply to this post by James E. Lang
Sorry, I accidentally sent my message to James instead of the mailing list.
 Let me recap what we discussed off-list.

James E Lang wrote:
>Correction: I meant SUMIF() rather than SUM().
>
>Corrected formula:
>
>=IF(___(A$3:A7,A7,Q$3:Q7)=___(A$3:A7,A7,R$3:R7),SUMIF(A$3:
A7,A7,R$3:R7)-SUMIF(A$3:A7,A7,Q$3:Q7),"Error 4")

If I understand the formula correctly, you simply would not need a 3rd
argument.  As I see it, the formula is looking at the values in column A
and checking which of those values matches the condition in A7.  Then you
want the formula to count the cells in column Q where the match occurred.
 But it does not matter which cells you count, because you only count the
matches in column A (which has nothing to do with column Q or R).

It seems difficult to explain what I mean, let me try an illustration:
There are 5 apples (3 red and 2 green) and 5 pears.  Each apple has a
number from 1 to 5 and each pear has a number from 1 to 5.  Count the pears
that have numbers that corrospond to red apples.  The answer would be 3.
 But you could just have counted how many apples are red.

Maybe you just want something like this:
=IF(countif(Q$3:Q7,A7) = countif(R$3:R7,A7),SUMIF(A$3:
A7,A7,R$3:R7)-SUMIF(A$3:A7,A7,Q$3:Q7),"Error 4")

That said, it is difficult to visualise the goal of the formula.  I suspect
I don't quite know what you want.  If you could upload a sample document
(with sensitive data removed) it might be easier to understand.

Regards
Stephan

--
To unsubscribe e-mail to: [hidden email]
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted

Brian Barker Brian Barker
Reply | Threaded
Open this post in threaded view
|

Re: Calc Function

In reply to this post by James E. Lang
At 10:17 11/01/2014 -0800, James E Lang wrote:

>Please fill in the blank ("___") below with a function name or tell
>me there is no such function:
>
>SUM(range) is to SUMIF(range1,criteria,range2) as COUNT(range) is to
>___(range1,criteria,range2)
>
>COUNTIF would seem to be the logical answer but I don't think it
>supports the third parameter and thus it is not analogous to COUNT.
>
>I'm wanting to use it as follows:
>
>=IF(___(A$3:A7,A7,Q$3:Q7)=___(A$3:A7,A7,R$3:R7),SUM(A$3:A7,A7,R$3:R7)-SUM(A$3:A7,A7,Q$3:Q7),"Error
>4")
>
>Where Error 4 means that the start miles in Q$3:Q7 and end miles in
>R$3:R7 are not properly paired and thus the miles driven on date A7
>cannot be determined.

Your formula - if it worked - would count the cells in columns Q and
R which correspond to cells in column A which match your criterion
for the contents of the cells in column A.  As has already been
pointed out, this is no different from counting the relevant cells in
column A - and this means that your test of equality will always be
true and your error message will never be triggered.  The COUNTIF(),
even if you could use it as you hoped, would pick out the appropriate
date but not take any account of the contents of the cells in columns
Q and R.  (This is no doubt why COUNTIF() cannot have that third
parameter: it would be of no use!)

>... the corresponding cell in column Q or R respectively contains a
>number (otherwise it's a zero length string).

At no point have you tested the contents of relevant cells in columns
Q and R, which would be counted even if they were empty.

But more fundamentally, counting such cells is surely an insufficient
test anyway: if you have the same number of missing "start miles" as
missing "end miles", your counts would match up (and no error would
be triggered) even if the missing values were in different rows.

I trust this helps.

Brian Barker


--
To unsubscribe e-mail to: [hidden email]
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted