RANK(value, direction, [precision,] grouping)


Ranking provides information about a group member’s or datapoint’s standing when compared against other members/datapoints.


This function takes:

  • A property or aggregate to rank
  • A sort direction (ASC or DESC)
  • An optional precision to which values will be rounded prior to being ranked
  • The grouping over which the records should be ranked


To see examples of reports using ranking, click here.


Notes:

  • ToolZ uses “sports ranking
  • NULL items are always sorted to the end of the list and ranked last


{|RESULT|}

  <table class='data'>

    <thead>

      <tr>

        <th>ID</th>

        <th>Date</th>

        <th>Score</th>

        <th>Rank Overall</th>

        <th>Rank in Month</th>

      </tr>

    </thead>

    <tbody>

      {|LOOP|RESULT.DATAPOINTS}

      <tr>

        <th>{DATAPOINTS.DATAPOINT_ID}</th>

        <td>{DATAPOINTS.TRENDING_TIMESTAMP}</td>

        <td>{DATAPOINTS.SCORE}</td>

        #the datapoint's rank out of all datapoints

        <td>{RANK(DATAPOINTS.SCORE,DESC,OVERALL)}</td>

        #the datapoint's rank out of datapoints in the same month-year

        <td>{RANK(DATAPOINTS.SCORE,DESC,MONTH_YEAR)}</td>

      </tr>

      {/|LOOP|}

    </tbody>

  </table>

{/|RESULT|}



{|NESTED|}

  <table class='data'>

    <thead>

      <tr>

        <th>Year</th>

        <th>Month</th>

        <th>Average Score</th>

        <th>Rank Overall</th>

        <th>Rank in Year</th>

      </tr>

    </thead>

    <tbody>

  {|LOOP|NESTED.YEAR(SORT=ORDER_NUM)}

    <tr>

      <th>{YEAR.NAME}</th>

      <td></td>

      #this year's average score

      <td>{AVG(YEAR.SCORE,YEAR)}</td>

      #this year's average score ranked against all other years, 

      #highest to lowest, rounded to 2 decimal places

      <td>{RANK(AVG(YEAR.SCORE,YEAR), DESC, 2, OVERALL)}</td>

      <td></td>

    </tr>

    {|LOOP|YEAR.MONTH_OF_YEAR(SORT=ORDER_NUM)}

      <tr>

        <th></th>

        <td>{MONTH_OF_YEAR.NAME}</td>

        <td>{AVG(MONTH_OF_YEAR.SCORE)}</td>

        #this month's average score ranked against all other months/years, 

        #highest to lowest, rounded to 2 decimal places

        <td>{RANK(AVG(MONTH_OF_YEAR.SCORE), DESC, 2, OVERALL)}</td>

        #this month's average score ranked against all other months in the

        #same year, highest to lowest, rounded to 2 decimal places

        <td>{RANK(AVG(MONTH_OF_YEAR.SCORE), DESC, 2, YEAR)}</td>

      </tr>

    {/|LOOP|}

  {/|LOOP|}

    </tbody>

  </table>

{/|NESTED|}