You are here

public static function PHPExcel_Calculation_Statistical::LARGE 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::LARGE()

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

Parameters

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

File

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

Class

PHPExcel_Calculation_Statistical
PHPExcel_Calculation_Statistical

Code

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

  // Calculate
  $entry = floor(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();
    }
    rsort($mArgs);
    return $mArgs[$entry];
  }
  return PHPExcel_Calculation_Functions::VALUE();
}