{
  "category": "Compatibility",
  "display_name": "RANK",
  "entry_kind": "built_in_function",
  "eval_api": {
    "method": "POST",
    "url": "https://handbook.dnacalc.com/api/eval"
  },
  "function_id": "FUNC.RANK",
  "implementation_state": {
    "answer_bank": null,
    "detail": "Recorded: 6 workbook cells.",
    "dnacalc_commit": "9e1884369a678158dd82d3d74188daf986995e87",
    "in_catalogue": true,
    "state": "matches",
    "state_label": "Matches every recorded Excel answer",
    "summary": "Matches all 6 recorded answers",
    "workbook_corpus": {
      "cells": 6,
      "matched": 6
    }
  },
  "implementations": [
    {
      "commit": "9e1884369a678158dd82d3d74188daf986995e87",
      "flavour": "excel-compatibility-candidate",
      "language": "Rust",
      "name": "CalcFunc",
      "own_code": [
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/statistics.rs#L299-L299"
      ],
      "repository": "https://github.com/DnaCalc/DnaCalc",
      "shared_code": [
        "catalogue/statistics::list",
        "catalogue/statistics::rank_number",
        "catalogue/statistics::rank",
        "ported/rank_common::rank_eq",
        "ported/rank_common::rank_avg"
      ],
      "source": "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/statistics.rs#L299-L299",
      "state": "matches",
      "suite": null,
      "summary": "Matches all 6 recorded answers"
    }
  ],
  "json_url": "https://handbook.dnacalc.com/api/functions/FUNC.RANK.json",
  "name": "RANK",
  "notes": [],
  "schema": "efh.function-reference/v1",
  "section_order": [
    "what-it-does",
    "try-it",
    "quirks",
    "how-to-implement",
    "version-differences",
    "alternatives"
  ],
  "sections": {
    "alternatives": "\n[RANK.EQ](FUNC.RANK.EQ.md) makes this tie rule explicit; [RANK.AVG](FUNC.RANK.AVG.md) averages tied positions; [PERCENTRANK.INC](FUNC.PERCENTRANK.INC.md) returns fractional standing.\n\n\n",
    "how-to-implement": "\n1. Validate the target as the current wrapper does: preserve a numeric value or worksheet error; other target kinds give `#N/A`.\n2. Collect the reference’s numeric observations. Coerce and truncate a supplied order flag, then test zero versus nonzero.\n3. Confirm the target occurs. If it is absent, return `#N/A`.\n4. Descending rank is `1+count(value>target)`; ascending rank is `1+count(value<target)`. Equal observations contribute no preceding positions, so each member of a tie receives the same result.\n\nWith `30,20,20,10`, only thirty exceeds twenty, giving rank two. All three other observations exceed ten, giving rank four. In ascending order thirty is fourth rather than first.\n\nFor a single query, counting avoids sorting and uses exact comparisons of the admitted numeric values. A sorted index can support many queries, provided it retains multiplicities and the same equality rule. Pairing this function with ROW-based tie breakers produces unique positions, which is a different ranking convention.\n\n\n",
    "quirks": "\nText, logical values and blanks in the reference are ignored, while zeros and repeated numbers remain observations. Ties share their first occupied rank; they do not receive consecutive ranks or an average. A number absent from the admitted data gives `#N/A` in the current helper.\n\nMicrosoft describes any nonzero `order` as ascending. The current wrapper truncates its numeric order toward zero before testing it, so fractional flags between minus one and one select descending. That is an implementation rule, not a measured statement about every Excel build. A nonnumeric target is also `#N/A` in this wrapper; it is not automatically parsed from numeric-looking text.\n\n\n",
    "sources": "\n- [Microsoft: RANK function](https://support.microsoft.com/en-us/excel/functions/rank-function), opened 6 November 2026; syntax, documented argument rules and errors.\n- [DnaCalc implementation](https://github.com/DnaCalc/DnaCalc/blob/da3ecc4fb19a3a5529708c311d0e8f05688ac165/crates/calc-func/src/catalogue/statistics.rs); implementation steps and the limits identified in the text.\n\n",
    "try-it": "\nWith `30,20,20,10` in B2:B5, `=RANK(20,B2:B5)` returns `2`. Both twenties have rank two and the ten has rank four: ties leave a gap.\n\n\n",
    "version-differences": "\nNo same-input comparison between named Excel builds is recorded for this function here. The documented behaviour below is not a measurement of every Excel release.\n\n\n",
    "what-it-does": "\n`RANK(number,ref,[order])` returns a number’s position within numeric observations. The default order is descending, so the largest value has rank one; a nonzero order requests ascending rank. It is the compatibility spelling of the tied-equal rank.\n\n\n"
  },
  "signature": {
    "display": "RANK(number, ref, [order])",
    "parameters": [
      {
        "description": null,
        "name": "number",
        "optional": false,
        "repeats": false
      },
      {
        "description": null,
        "name": "ref",
        "optional": false,
        "repeats": false
      },
      {
        "description": null,
        "name": "order",
        "optional": true,
        "repeats": false
      }
    ],
    "trailing_repeats": false
  },
  "sources": {
    "metadata": {
      "admission": {
        "label": "implemented",
        "reason": null
      },
      "arity": {
        "max": 3,
        "min": 2
      },
      "category": "Compatibility",
      "classification": {
        "arg_preparation_profile": "ValuesOnlyPreAdapter",
        "coercion_lift_profile": "Custom",
        "determinism_class": "Deterministic",
        "error_collapse_profile": "None",
        "fec_dependency_profile": "None",
        "host_interaction_class": "None",
        "kernel_signature_class": "Custom",
        "rich_value_usage": "RichBlind",
        "surface_fec_dependency_profile": "RefOnly",
        "thread_safety_class": "SafePure",
        "volatility_class": "NonVolatile"
      },
      "descriptions": {
        "long": null,
        "short": "Rank of a number in a list (older form of RANK.EQ)",
        "short_source": "dna-calc-own"
      },
      "docs": {
        "english_description": "Returns the rank of a number in a list of numbers",
        "microsoft_url": "https://support.microsoft.com/en-us/office/rank-function-6a2fc49d-1831-4a03-9d8c-c279cf99f723"
      },
      "entry_kind": "built_in_function",
      "localized_family_names": null,
      "localized_names": [
        {
          "locale": "ar-SA",
          "name": "RANK"
        },
        {
          "locale": "bg-BG",
          "name": "RANK"
        },
        {
          "locale": "cs-CZ",
          "name": "RANK"
        },
        {
          "locale": "da-DK",
          "name": "PLADS"
        },
        {
          "locale": "de-DE",
          "name": "RANK"
        },
        {
          "locale": "el-GR",
          "name": "RANK"
        },
        {
          "locale": "en-AU",
          "name": "RANK"
        },
        {
          "locale": "en-GB",
          "name": "RANK"
        },
        {
          "locale": "en-US",
          "name": "RANK"
        },
        {
          "locale": "es-ES",
          "name": "JERARQUIA"
        },
        {
          "locale": "et-EE",
          "name": "RANK"
        },
        {
          "locale": "fi-FI",
          "name": "ARVON.MUKAAN"
        },
        {
          "locale": "fr-FR",
          "name": "RANG*"
        },
        {
          "locale": "he-IL",
          "name": "RANK"
        },
        {
          "locale": "hr-HR",
          "name": "RANK"
        },
        {
          "locale": "hu-HU",
          "name": "SORSZÁM"
        },
        {
          "locale": "id-ID",
          "name": "RANK"
        },
        {
          "locale": "it-IT",
          "name": "RANK"
        },
        {
          "locale": "ja-JP",
          "name": "RANK"
        },
        {
          "locale": "ko-KR",
          "name": "RANK"
        },
        {
          "locale": "lt-LT",
          "name": "RANK"
        },
        {
          "locale": "lv-LV",
          "name": "RANK"
        },
        {
          "locale": "nb-NO",
          "name": "RANGERING"
        },
        {
          "locale": "nl-NL",
          "name": "POSITIE"
        },
        {
          "locale": "pl-PL",
          "name": "POZYCJA"
        },
        {
          "locale": "pt-BR",
          "name": "CLASSIFICAÇÃO"
        },
        {
          "locale": "pt-PT",
          "name": "ORDEM"
        },
        {
          "locale": "ro-RO",
          "name": "RANK"
        },
        {
          "locale": "ru-RU",
          "name": "РАНГ"
        },
        {
          "locale": "sk-SK",
          "name": "PORADIE"
        },
        {
          "locale": "sl-SI",
          "name": "RANK"
        },
        {
          "locale": "sr-Latn-RS",
          "name": "RANGIRANJE"
        },
        {
          "locale": "sv-SE",
          "name": "RANG"
        },
        {
          "locale": "th-TH",
          "name": "RANK"
        },
        {
          "locale": "tr-TR",
          "name": "RANK"
        },
        {
          "locale": "uk-UA",
          "name": "RANK"
        },
        {
          "locale": "vi-VN",
          "name": "RANK"
        },
        {
          "locale": "zh-CN",
          "name": "RANK"
        },
        {
          "locale": "zh-HK",
          "name": "RANK"
        },
        {
          "locale": "zh-TW",
          "name": "RANK"
        }
      ],
      "signature": {
        "display": "RANK(number, ref, [order])",
        "parameters": [
          {
            "description": null,
            "name": "number",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "ref",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "order",
            "optional": true,
            "repeats": false
          }
        ],
        "trailing_repeats": false
      },
      "surface_name": "RANK",
      "version_marker": null,
      "xlcall": {
        "code": "216",
        "symbol": "xlfRank"
      }
    },
    "microsoft": "https://support.microsoft.com/en-us/office/rank-function-6a2fc49d-1831-4a03-9d8c-c279cf99f723"
  },
  "try_it": {
    "formula": "=RANK(20,B2:B5)",
    "inputs": {
      "B2": 30,
      "B3": 20,
      "B4": 20,
      "B5": 10
    }
  },
  "url": "https://handbook.dnacalc.com/functions/RANK.html",
  "variants": [],
  "versions": []
}