You are here

public static function PHPExcel_Calculation_Statistical::SMALL in Loft Data Grids 6.2

Same name and namespace in other branches
  1. 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Statistical.php \PHPExcel_Calculation_Statistical::SMALL()

* SMALL * * Returns the nth smallest value in a data set. You can use this function to * select a value based on its relative standing. * * Excel Function: * SMALL(value1[,value2[, ...]],entry) * * @access public * @category Statistical Functions *

Parameters

mixed $arg,... Data values: * @param int $entry Position (ordered from the smallest) in the array or range of data to return * @return float

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Statistical.php, line 2932

Class

PHPExcel_Calculation_Statistical
PHPExcel_Calculation_Statistical

Code

public static function SMALL() {
  $aArgs = PHPExcel_Calculation_Functions::flattenArray(func_get_args());

  // Calculate
  $entry = array_pop($aArgs);
  if (is_numeric($entry) && !is_string($entry)) {
    $mArgs = array();
    foreach ($aArgs as $arg) {

      // Is it a numeric value?
      if (is_numeric($arg) && !is_string($arg)) {
        $mArgs[] = $arg;
      }
    }
    $count = self::COUNT($mArgs);
    $entry = floor(--$entry);
    if ($entry < 0 || $entry >= $count || $count == 0) {
      return PHPExcel_Calculation_Functions::NaN();
    }
    sort($mArgs);
    return $mArgs[$entry];
  }
  return PHPExcel_Calculation_Functions::VALUE();
}