sc/qa/unit/data/contentCSV/statistical-functions.csv |    6 +++---
 sc/qa/unit/data/ods/functions.ods                    |binary
 sc/source/core/tool/interpr3.cxx                     |    8 ++++++--
 3 files changed, 9 insertions(+), 5 deletions(-)

New commits:
commit 92ac45898fe6715b7dd5e12831af6f7d3df119e3
Author:     Eike Rathke <er...@redhat.com>
AuthorDate: Thu Apr 6 14:41:39 2023 +0200
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Fri Apr 7 17:52:56 2023 +0200

    Resolves: tdf#154627 RANK() query value not in data must return error
    
    For all RANK(), RANK.EQ(), RANK.AVG().
    Also, use #N/A NotAvailable instead of #VALUE! NoValue.
    
    This made it necessary to adapt sc/qa/unit/data/ods/functions.ods and
    result check that had a totally senseless query value with arbitrary
    results.
    
    Change-Id: If835b5ed49caf16a813b4ea897e1d7dd1aa02954
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150067
    Reviewed-by: Eike Rathke <er...@redhat.com>
    Tested-by: Jenkins
    (cherry picked from commit 14874c539e0ae55c77d752fc6870367b6ebcad9a)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150084
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/sc/qa/unit/data/contentCSV/statistical-functions.csv 
b/sc/qa/unit/data/contentCSV/statistical-functions.csv
index 2e3c45cdb4a3..b9dbe2f2fbd9 100644
--- a/sc/qa/unit/data/contentCSV/statistical-functions.csv
+++ b/sc/qa/unit/data/contentCSV/statistical-functions.csv
@@ -117,9 +117,9 @@
 1
 -0.1225598712
 -0.1363480926
-2
-9
-2
+10
+11
+10
 0.5,0.1
 121,216
 120
diff --git a/sc/qa/unit/data/ods/functions.ods 
b/sc/qa/unit/data/ods/functions.ods
index 04c6e6ed1274..1ef3a7217b34 100644
Binary files a/sc/qa/unit/data/ods/functions.ods and 
b/sc/qa/unit/data/ods/functions.ods differ
diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx
index c20d7e0327e1..d9149b978e2e 100644
--- a/sc/source/core/tool/interpr3.cxx
+++ b/sc/source/core/tool/interpr3.cxx
@@ -4248,7 +4248,7 @@ void ScInterpreter::ScRank( bool bAverage )
     else
     {
         if ( fVal < aSortArray[ 0 ] || fVal > aSortArray[ nSize - 1 ] )
-            PushNoValue();
+            PushError( FormulaError::NotAvailable);
         else
         {
             double fLastPos = 0;
@@ -4273,7 +4273,11 @@ void ScInterpreter::ScRank( bool bAverage )
             }
             if ( !bFinished )
                 fLastPos = i;
-            if ( !bAverage )
+            if (fFirstPos <= 0)
+            {
+                PushError( FormulaError::NotAvailable);
+            }
+            else if ( !bAverage )
             {
                 if ( bAscending )
                     PushDouble( fFirstPos );

Reply via email to