Forum Discussion

pevenden's avatar
pevenden
Brass Contributor
May 31, 2026

sort by column then by numbers in a row

HI all

I have a table of results pictured here. Once the results are in, I sort the table by the Total Score Column. When we have a tie (as in line 3 & 4, I need to sort by who has the most highest score... so, who has the most 9 (equal here), then by most 8.5 (line 4 wins the tiebreaker, 4 over 2)

Can I do this so it doesn't affect the order of the columns but just the rows involved. 

 

7 Replies

  • pevenden's avatar
    pevenden
    Brass Contributor

    Thanks all

    I have Excel 2024.

    I have put djclements suggestions in the spreadsheet and that seems to work great... so thanks all for the help...

     

    now, the trick is to understand why I am doing all of this so I can understand the processes involved! LOL

    not for discussion here of course... 

  • IlirU's avatar
    IlirU
    Iron Contributor

    Hi pevenden​,

    Does this formula help you? I have applied it to cell S1 (see screenshot). Try it and let me know.

    =LET(
    data, A1:Q9,
      dr, DROP(data, 1),
          VSTACK(TAKE(data, 1), CHOOSECOLS(SORT(HSTACK(dr, --TEXTSPLIT(TEXTJOIN(";",,
            BYROW(CHOOSECOLS(dr, SEQUENCE(, 13, 4)),
                  LAMBDA(b, ARRAYTOTEXT(BYCOL(SEQUENCE(, 9, 9, -0.5),
                  LAMBDA(a, SUM(--(b = a)))))))), ", ", ";")), SEQUENCE(, 10, 17),
                 -SIGN(SEQUENCE(, 10))), SEQUENCE(, 17)))
    )

    HTH

    IlirU

    • m_tarler's avatar
      m_tarler
      Silver Contributor

      alternatively you could just add a 'RANK' column and then use built in sorting to rearrange the current table instead of creating a separate table.  Here is a relatively generic option (i.e. doesn't assume 9 is the max or the number of columns) to create that 'RANK' column:

      =LET(in,A1:.G99,
      max_count, COLUMNS(in),
      rcount, SEQUENCE(ROWS(in)),
      uniq_vals, SORT(UNIQUE(TOCOL(in)),,-1),
      rankrow, BYROW(in,LAMBDA(r, CONCAT(TEXT(MMULT(--(r=uniq_vals),EXPAND(1,max_count,,1)),"00")))),
      SORTBY(rcount,SORTBY(rcount,BYROW(in,SUM),-1,rankrow,-1)))

      where you just need to change the A1:.G99 to the corresponding range of values.

      I currently 'ranks' them with 1 being the highest but replace both of the '-1' in the last line with '1' and you can have it 'rank' with 1 being the lowest and the highest having the biggest value.

      • pevenden's avatar
        pevenden
        Brass Contributor

        I've put your formula into one line in the formula bar, in cell W6 as follows:

        =LET(in,B6:T52,max_count, COLUMNS(in),rcount, SEQUENCE(ROWS(in)),uniq_vals, SORT(UNIQUE(TOCOL(in)),,-1),rankrow, BYROW(in,LAMBDA(r, CONCAT(TEXT(MMULT(--(r=uniq_vals),EXPAND(1,max_count,,1)),"00")))),SORTBY(rcount,SORTBY(rcount,BYROW(in,SUM),-1,rankrow,1)))

        Direct copy from above, but I get a #NAME? error.

        I have adjusted the cell references for my table. I want to rank from highest to lowest. 

        when working with the table, I filter and remove the blanks.