[gnumeric] Funcs: add MINIFS and MAXIFS.



commit 24e5ae72e0d19f95a29e28f24aeac96897d22bc5
Author: Morten Welinder <terra gnome org>
Date:   Mon Aug 8 09:22:46 2016 -0400

    Funcs: add MINIFS and MAXIFS.

 NEWS                                  |    2 +
 doc/C/func.defs                       |   30 +++++++++++--
 doc/C/functions.xml                   |   74 ++++++++++++++++++++++++++++++++-
 plugins/fn-math/functions.c           |   51 ++++++++++++++++++++++-
 plugins/fn-math/plugin.xml.in         |    2 +
 plugins/openoffice/openoffice-read.c  |    2 +
 plugins/openoffice/openoffice-write.c |    2 +
 7 files changed, 156 insertions(+), 7 deletions(-)
---
diff --git a/NEWS b/NEWS
index 774bf1d..023585f 100644
--- a/NEWS
+++ b/NEWS
@@ -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.
 
 --------------------------------------------------------------------------
diff --git a/doc/C/func.defs b/doc/C/func.defs
index 22ebf50..5c2eff2 100644
--- a/doc/C/func.defs
+++ b/doc/C/func.defs
@@ -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
@@ -3671,6 +3672,16 @@ The depreciation coefficient used is:
 @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}
 @SYNTAX=MDETERM(matrix)
@@ -3679,6 +3690,16 @@ The depreciation coefficient used is:
 @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}
 @SYNTAX=MINVERSE(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
diff --git a/doc/C/functions.xml b/doc/C/functions.xml
index c9e5f17..92ff0d4 100644
--- a/doc/C/functions.xml
+++ b/doc/C/functions.xml
@@ -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>
diff --git a/plugins/fn-math/functions.c b/plugins/fn-math/functions.c
index 7076d9e..a640ea5 100644
--- a/plugins/fn-math/functions.c
+++ b/plugins/fn-math/functions.c
@@ -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 },
diff --git a/plugins/fn-math/plugin.xml.in b/plugins/fn-math/plugin.xml.in
index 20ad314..90089c9 100644
--- a/plugins/fn-math/plugin.xml.in
+++ b/plugins/fn-math/plugin.xml.in
@@ -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"/>
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index fece921..d57255a 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -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" },
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index e74a5da..000a703 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -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" },


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]