Commit 24e5ae72 authored by Morten Welinder's avatar Morten Welinder

Funcs: add MINIFS and MAXIFS.

parent ddb17b84
......@@ -14,6 +14,8 @@ Morten:
* New function SWITCH.
* New function SUMIFS.
* New function AVERAGEIFS.
* New function MINIFS.
* New function MAXIFS.
* Fix criteria function issue with errors in the selector area.
--------------------------------------------------------------------------
......
......@@ -3311,8 +3311,9 @@ The depreciation coefficient used is:
@CATEGORY=Mathematics
@FUNCTION=AVERAGEIFS
@SHORTDESC=average of the cells in @{actual_range} for which the corresponding cells in the range meet the given criteria
@SYNTAX=AVERAGEIFS(range1,criteria1,…)
@ARGUMENTDESCRIPTION=@{range1}: cell area
@SYNTAX=AVERAGEIFS(actual_range,range1,criteria1,…)
@ARGUMENTDESCRIPTION=@{actual_range}: cell area
@{range1}: cell area
@{criteria1}: condition for a cell to be included
@EXCEL=This function is Excel compatible.
@SEEALSO=AVERAGE,AVERAGEIF
......@@ -3670,6 +3671,16 @@ The depreciation coefficient used is:
@NOTE=If @{x} ≤ 0, LOG2 returns #NUM!
@SEEALSO=EXP,LOG10,LOG
@CATEGORY=Mathematics
@FUNCTION=MAXIFS
@SHORTDESC=maximum of the cells in @{actual_range} for which the corresponding cells in the range meet the given criteria
@SYNTAX=MAXIFS(actual_range,range1,criteria1,…)
@ARGUMENTDESCRIPTION=@{actual_range}: cell area
@{range1}: cell area
@{criteria1}: condition for a cell to be included
@EXCEL=This function is Excel compatible.
@SEEALSO=MIN,MINIFS
@CATEGORY=Mathematics
@FUNCTION=MDETERM
@SHORTDESC=the determinant of the matrix @{matrix}
......@@ -3678,6 +3689,16 @@ The depreciation coefficient used is:
@EXCEL=This function is Excel compatible.
@SEEALSO=MMULT,MINVERSE
@CATEGORY=Mathematics
@FUNCTION=MINIFS
@SHORTDESC=minimum of the cells in @{actual_range} for which the corresponding cells in the range meet the given criteria
@SYNTAX=MINIFS(actual_range,range1,criteria1,…)
@ARGUMENTDESCRIPTION=@{actual_range}: cell area
@{range1}: cell area
@{criteria1}: condition for a cell to be included
@EXCEL=This function is Excel compatible.
@SEEALSO=MIN,MAXIFS
@CATEGORY=Mathematics
@FUNCTION=MINVERSE
@SHORTDESC=the inverse matrix of @{matrix}
......@@ -3975,8 +3996,9 @@ If @{d} is less than zero, @{x} is rounded away from 0 to the left of the decima
@CATEGORY=Mathematics
@FUNCTION=SUMIFS
@SHORTDESC=sum of the cells in @{actual_range} for which the corresponding cells in the range meet the given criteria
@SYNTAX=SUMIFS(range1,criteria1,…)
@ARGUMENTDESCRIPTION=@{range1}: cell area
@SYNTAX=SUMIFS(actual_range,range1,criteria1,…)
@ARGUMENTDESCRIPTION=@{actual_range}: cell area
@{range1}: cell area
@{criteria1}: condition for a cell to be included
@EXCEL=This function is Excel compatible.
@SEEALSO=SUM,SUMIF
......
......@@ -10762,10 +10762,11 @@
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<synopsis><function>AVERAGEIFS</function>(<parameter>range1</parameter>,<parameter>criteria1</parameter>,<parameter/>…)</synopsis>
<synopsis><function>AVERAGEIFS</function>(<parameter>actual_range</parameter>,<parameter>range1</parameter>,<parameter>criteria1</parameter>,<parameter/>…)</synopsis>
</refsynopsisdiv>
<refsect1>
<title>Arguments</title>
<para><parameter>actual_range</parameter>: cell area</para>
<para><parameter>range1</parameter>: cell area</para>
<para><parameter>criteria1</parameter>: condition for a cell to be included</para>
</refsect1>
......@@ -12162,6 +12163,40 @@
</para>
</refsect1>
</refentry>
<refentry id="gnumeric-function-MAXIFS">
<refmeta>
<refentrytitle>
<function>MAXIFS</function>
</refentrytitle>
</refmeta>
<refnamediv>
<refname>
<function>MAXIFS</function>
</refname>
<refpurpose>
maximum of the cells in <parameter>actual_range</parameter> for which the corresponding cells in the range meet the given criteria
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<synopsis><function>MAXIFS</function>(<parameter>actual_range</parameter>,<parameter>range1</parameter>,<parameter>criteria1</parameter>,<parameter/>…)</synopsis>
</refsynopsisdiv>
<refsect1>
<title>Arguments</title>
<para><parameter>actual_range</parameter>: cell area</para>
<para><parameter>range1</parameter>: cell area</para>
<para><parameter>criteria1</parameter>: condition for a cell to be included</para>
</refsect1>
<refsect1>
<title>Microsoft Excel Compatibility</title>
<para>This function is Excel compatible.</para>
</refsect1>
<refsect1>
<title>See also</title>
<para><link linkend="gnumeric-function-MIN"><function>MIN</function></link>,
<link linkend="gnumeric-function-MINIFS"><function>MINIFS</function></link>.
</para>
</refsect1>
</refentry>
<refentry id="gnumeric-function-MDETERM">
<refmeta>
<refentrytitle>
......@@ -12194,6 +12229,40 @@
</para>
</refsect1>
</refentry>
<refentry id="gnumeric-function-MINIFS">
<refmeta>
<refentrytitle>
<function>MINIFS</function>
</refentrytitle>
</refmeta>
<refnamediv>
<refname>
<function>MINIFS</function>
</refname>
<refpurpose>
minimum of the cells in <parameter>actual_range</parameter> for which the corresponding cells in the range meet the given criteria
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<synopsis><function>MINIFS</function>(<parameter>actual_range</parameter>,<parameter>range1</parameter>,<parameter>criteria1</parameter>,<parameter/>…)</synopsis>
</refsynopsisdiv>
<refsect1>
<title>Arguments</title>
<para><parameter>actual_range</parameter>: cell area</para>
<para><parameter>range1</parameter>: cell area</para>
<para><parameter>criteria1</parameter>: condition for a cell to be included</para>
</refsect1>
<refsect1>
<title>Microsoft Excel Compatibility</title>
<para>This function is Excel compatible.</para>
</refsect1>
<refsect1>
<title>See also</title>
<para><link linkend="gnumeric-function-MIN"><function>MIN</function></link>,
<link linkend="gnumeric-function-MAXIFS"><function>MAXIFS</function></link>.
</para>
</refsect1>
</refentry>
<refentry id="gnumeric-function-MINVERSE">
<refmeta>
<refentrytitle>
......@@ -13315,10 +13384,11 @@
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<synopsis><function>SUMIFS</function>(<parameter>range1</parameter>,<parameter>criteria1</parameter>,<parameter/>…)</synopsis>
<synopsis><function>SUMIFS</function>(<parameter>actual_range</parameter>,<parameter>range1</parameter>,<parameter>criteria1</parameter>,<parameter/>…)</synopsis>
</refsynopsisdiv>
<refsect1>
<title>Arguments</title>
<para><parameter>actual_range</parameter>: cell area</para>
<para><parameter>range1</parameter>: cell area</para>
<para><parameter>criteria1</parameter>: condition for a cell to be included</para>
</refsect1>
......
......@@ -786,6 +786,7 @@ gnumeric_sumif (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
static GnmFuncHelp const help_sumifs[] = {
{ GNM_FUNC_HELP_NAME, F_("SUMIFS:sum of the cells in @{actual_range} for which the corresponding cells in the range meet the given criteria")},
{ GNM_FUNC_HELP_ARG, F_("actual_range:cell area")},
{ GNM_FUNC_HELP_ARG, F_("range1:cell area")},
{ GNM_FUNC_HELP_ARG, F_("criteria1:condition for a cell to be included")},
{ GNM_FUNC_HELP_EXCEL, F_("This function is Excel compatible.") },
......@@ -821,6 +822,7 @@ gnumeric_averageif (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
static GnmFuncHelp const help_averageifs[] = {
{ GNM_FUNC_HELP_NAME, F_("AVERAGEIFS:average of the cells in @{actual_range} for which the corresponding cells in the range meet the given criteria")},
{ GNM_FUNC_HELP_ARG, F_("actual_range:cell area")},
{ GNM_FUNC_HELP_ARG, F_("range1:cell area")},
{ GNM_FUNC_HELP_ARG, F_("criteria1:condition for a cell to be included")},
{ GNM_FUNC_HELP_EXCEL, F_("This function is Excel compatible.") },
......@@ -831,7 +833,46 @@ static GnmFuncHelp const help_averageifs[] = {
static GnmValue *
gnumeric_averageifs (GnmFuncEvalInfo *ei, int argc, GnmExprConstPtr const *argv)
{
return newstyle_if_func (ei, argc, argv, gnm_range_sum, GNM_ERROR_DIV0);
return newstyle_if_func (ei, argc, argv,
gnm_range_average, GNM_ERROR_DIV0);
}
/***************************************************************************/
static GnmFuncHelp const help_minifs[] = {
{ GNM_FUNC_HELP_NAME, F_("MINIFS:minimum of the cells in @{actual_range} for which the corresponding cells in the range meet the given criteria")},
{ GNM_FUNC_HELP_ARG, F_("actual_range:cell area")},
{ GNM_FUNC_HELP_ARG, F_("range1:cell area")},
{ GNM_FUNC_HELP_ARG, F_("criteria1:condition for a cell to be included")},
{ GNM_FUNC_HELP_EXCEL, F_("This function is Excel compatible.") },
{ GNM_FUNC_HELP_SEEALSO, "MIN,MAXIFS"},
{ GNM_FUNC_HELP_END}
};
static GnmValue *
gnumeric_minifs (GnmFuncEvalInfo *ei, int argc, GnmExprConstPtr const *argv)
{
return newstyle_if_func (ei, argc, argv,
gnm_range_min, GNM_ERROR_DIV0);
}
/***************************************************************************/
static GnmFuncHelp const help_maxifs[] = {
{ GNM_FUNC_HELP_NAME, F_("MAXIFS:maximum of the cells in @{actual_range} for which the corresponding cells in the range meet the given criteria")},
{ GNM_FUNC_HELP_ARG, F_("actual_range:cell area")},
{ GNM_FUNC_HELP_ARG, F_("range1:cell area")},
{ GNM_FUNC_HELP_ARG, F_("criteria1:condition for a cell to be included")},
{ GNM_FUNC_HELP_EXCEL, F_("This function is Excel compatible.") },
{ GNM_FUNC_HELP_SEEALSO, "MIN,MINIFS"},
{ GNM_FUNC_HELP_END}
};
static GnmValue *
gnumeric_maxifs (GnmFuncEvalInfo *ei, int argc, GnmExprConstPtr const *argv)
{
return newstyle_if_func (ei, argc, argv,
gnm_range_max, GNM_ERROR_DIV0);
}
/***************************************************************************/
......@@ -3630,6 +3671,14 @@ GnmFuncDescriptor const math_functions[] = {
NULL, gnumeric_averageifs, NULL, NULL,
GNM_FUNC_SIMPLE,
GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_NO_TESTSUITE },
{ "minifs", NULL, help_minifs,
NULL, gnumeric_minifs, NULL, NULL,
GNM_FUNC_SIMPLE,
GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_NO_TESTSUITE },
{ "maxifs", NULL, help_maxifs,
NULL, gnumeric_maxifs, NULL, NULL,
GNM_FUNC_SIMPLE,
GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_NO_TESTSUITE },
{ "sumproduct", NULL, help_sumproduct,
NULL, gnumeric_sumproduct, NULL, NULL,
GNM_FUNC_SIMPLE, GNM_FUNC_IMPL_STATUS_COMPLETE, GNM_FUNC_TEST_STATUS_BASIC },
......
......@@ -65,7 +65,9 @@
<function name="log"/>
<function name="log10"/>
<function name="log2"/>
<function name="maxifs"/>
<function name="mdeterm"/>
<function name="minifs"/>
<function name="minverse"/>
<function name="mmult"/>
<function name="mod"/>
......
......@@ -12932,6 +12932,8 @@ oo_func_map_in (GnmConventions const *convs, Workbook *scope,
{ "HYPGEOM.DIST","HYPGEOMDIST" },
{ "IFS","IFS" },
{ "LOGNORM.INV","LOGINV" },
{ "MINIFS", "MINIFS" },
{ "MAXIFS", "MAXIFS" },
{ "MODE.SNGL","MODE" },
{ "MODE.MULT","MODE.MULT" },
{ "NORM.DIST","NORMDIST" },
......
......@@ -2479,6 +2479,7 @@ odf_expr_func_handler (GnmConventionsOut *out, GnmExprFunction const *func)
{ "MATCH","MATCH" },
{ "MAX","MAX" },
{ "MAXA","MAXA" },
{ "MAXIFS","MAXIFS" },
{ "MDETERM","MDETERM" },
{ "MDURATION","MDURATION" },
{ "MEDIAN","MEDIAN" },
......@@ -2486,6 +2487,7 @@ odf_expr_func_handler (GnmConventionsOut *out, GnmExprFunction const *func)
{ "MIDB","MIDB" },
{ "MIN","MIN" },
{ "MINA","MINA" },
{ "MINIFS","MINIFS" },
{ "MINUTE","MINUTE" },
{ "MINVERSE","MINVERSE" },
{ "MIRR","MIRR" },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment