diff --git a/src/PhpSpreadsheet/Calculation/Calculation.php b/src/PhpSpreadsheet/Calculation/Calculation.php index 8cb1c297..99260e3b 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -1250,6 +1250,11 @@ class Calculation 'functionCall' => [Statistical::class, 'HYPGEOMDIST'], 'argumentCount' => '4', ], + 'HYPGEOM.DIST' => [ + 'category' => Category::CATEGORY_STATISTICAL, + 'functionCall' => [Functions::class, 'DUMMY'], + 'argumentCount' => '5', + ], 'IF' => [ 'category' => Category::CATEGORY_LOGICAL, 'functionCall' => [Logical::class, 'statementIf'], diff --git a/src/PhpSpreadsheet/Calculation/Statistical.php b/src/PhpSpreadsheet/Calculation/Statistical.php index 524438ea..4b113726 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical.php +++ b/src/PhpSpreadsheet/Calculation/Statistical.php @@ -1901,12 +1901,17 @@ class Statistical */ public static function HYPGEOMDIST($sampleSuccesses, $sampleNumber, $populationSuccesses, $populationNumber) { - $sampleSuccesses = floor(Functions::flattenSingleValue($sampleSuccesses)); - $sampleNumber = floor(Functions::flattenSingleValue($sampleNumber)); - $populationSuccesses = floor(Functions::flattenSingleValue($populationSuccesses)); - $populationNumber = floor(Functions::flattenSingleValue($populationNumber)); + $sampleSuccesses = Functions::flattenSingleValue($sampleSuccesses); + $sampleNumber = Functions::flattenSingleValue($sampleNumber); + $populationSuccesses = Functions::flattenSingleValue($populationSuccesses); + $populationNumber = Functions::flattenSingleValue($populationNumber); if ((is_numeric($sampleSuccesses)) && (is_numeric($sampleNumber)) && (is_numeric($populationSuccesses)) && (is_numeric($populationNumber))) { + $sampleSuccesses = floor($sampleSuccesses); + $sampleNumber = floor($sampleNumber); + $populationSuccesses = floor($populationSuccesses); + $populationNumber = floor($populationNumber); + if (($sampleSuccesses < 0) || ($sampleSuccesses > $sampleNumber) || ($sampleSuccesses > $populationSuccesses)) { return Functions::NAN(); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/HypGeomDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/HypGeomDistTest.php new file mode 100644 index 00000000..d05b60b5 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/HypGeomDistTest.php @@ -0,0 +1,25 @@ +