Search code examples
algorithmgoogle-sheetsstatisticsgoogle-sheets-formulaarray-formulas

How can I find the number of concordant/discordant pairs for a given cell in Google Sheets?


I am trying to figure out the Kendall's Tau coefficient of two different rankings in google sheets, and doing so would require finding the number of concordant and discordant pairs for a given cell. The number of concordant pairs for a given cell is the number of cells containing a larger number underneath the given cell, and the number of discordant pairs is the amount of smaller numbers beneath the cell. I am trying to figure out how to write a formula in google sheets (without using the API) that determines the number of concordant or discordant pairs that exist beneath a given cell. How can I accomplish this?


Solution

  • C2 cell:

    =ARRAYFORMULA(SUM(IFERROR(IF(A1:A<A2:A, 1, 0))))
    

    D2 cell:

    =ARRAYFORMULA(SUM(IFERROR(IF(A1:A>A2:A, 1, 0))))
    

    0