fbpx
Search
Close this search box.

Sorting values in Olympic Medal Table style [Quick Tip]

Share

Facebook
Twitter
LinkedIn

It is Olympic season. Everyone I know is tracking the games and checking their country’s performance. One thing that we notice when looking at medal tally is,

A single Gold medal is worth more than any number of Silver medals. Like wise, a single Silver medal is worth more than any number of Bronze medals.

So, when you look at the ranking of countries, you see countries with single Gold medal higher up than countries with lots of Silver and Bronze medals (but no Gold).

Sorting values in Olympic Medal Table style - Excel Tips

So how do we sort our data in Olympic medal table style?

It is simpler than it looks. All you have to do is use custom sort feature in Excel.

  1. Select your data
  2. Go to Home > Sort & Filter > Custom Sort
  3. Now specify the sort levels and sort orders.
  4. Click ok and you are done!

Using SORTBY() formula to sort the table

Excel 365 introduced a new formula to sort data by multiple-levels using formulas. SORTBY

Assuming your medal data is in the table named medals you can sort with below formula.

=SORTBY(medals, medals[Gold],-1, medals[Silver], -1, medals[Bronze],-1,
medals[Team / NOC],1)

The -1 parameter tells SORTBY to sort in descending order.

Learn more about SORTBY function & other new formulas in Excel 365.

What if your version of Excel does not have SORTBY

Well, there is a work around. Add an extra column in your data and calculate sort order using a formula, as shown below.

Using sort order calculation in Excel

Once you calculate sort order, sort on this column in descending order and you are done.

Video – Sorting Excel data in Olympic medal table style

Watch this short & fun video to learn the sorting technique outlined in this page.

Example file – Olympics Medal Table style sorting in Excel

Please download this Excel file if you want to practice the custom sort or SORTBY() approach.

Do you use custom sort?

Custom sorting is very useful when you 2-3 levels in your data. For example, sorting all projects by department & % completed or sorting all products by region & sales volume. I use it often to understand how my data is.

What about you? Do you use custom sort? What is your experience like? Please share your tips & thoughts using comments.

More Quick Tips on Sorting & Filtering

If you find yourself constantly sorting and filtering, then check out below tips. I am sure you will learn something new.

Facebook
Twitter
LinkedIn

Share this tip with your colleagues

Excel and Power BI tips - Chandoo.org Newsletter

Get FREE Excel + Power BI Tips

Simple, fun and useful emails, once per week.

Learn & be awesome.

Welcome to Chandoo.org

Thank you so much for visiting. My aim is to make you awesome in Excel & Power BI. I do this by sharing videos, tips, examples and downloads on this website. There are more than 1,000 pages with all things Excel, Power BI, Dashboards & VBA here. Go ahead and spend few minutes to be AWESOME.

Read my storyFREE Excel tips book

Excel School made me great at work.
5/5

– Brenda

Excel formula list - 100+ examples and howto guide for you

From simple to complex, there is a formula for every occasion. Check out the list now.

Calendars, invoices, trackers and much more. All free, fun and fantastic.

Advanced Pivot Table tricks

Power Query, Data model, DAX, Filters, Slicers, Conditional formats and beautiful charts. It's all here.

Still on fence about Power BI? In this getting started guide, learn what is Power BI, how to get it and how to create your first report from scratch.

letter grades from test scores in Excel

How to convert test scores to letter grades in Excel?

We can use Excel’s LOOKUP function to quickly convert exam or test scores to letter grades like A+ or F. In this article, let me explain the process and necessary formulas. I will also share a technique to calculate letter grades from test scores using percentiles.

29 Responses to “Sorting values in Olympic Medal Table style [Quick Tip]”

  1. Hui says:

    Chandoo's comment "Use a sufficiently large number in place of 30"
    should be
    "Use a sufficiently large number larger than the largest number in the Silver/Bronze categories" 
    In the example if a Team had 31 Silver they would rank higher than a team with only 1 gold

  2. David onder says:

    Why not just multiply gold by 1000000 and silver by 1000.  That is easier to read and the resulting number still shows the medal count.  23G, 12S and 1B is 23012001 and 1G, 24S, 3B is 1024003.

    David 

  3. lokesh says:

    hahahahahaha! David i agree with you.

  4. Luke M says:

    Or you could do it manually. Sort Bronze column in descending order, then Silver, then Gold. =)

  5. Clay says:

    What about

    =(gold  * (Max of Silver +1)^2) + (Silver * (Max of Bronze +1) )+ Bronze

    That controls for  a country that goes on a silver or bronze medal run.

  6. Stef@n says:

    Dear all
    another solution

    =gold + silver / 50  +  bronze / 2500

    or (for larger rows)

    =gold + silver / 100  +   bronze / 1000

    Regards
    Stef@n

    • David Onder says:

      This is similar to mine above but moves the silver and bronze to after the decimal.  One thing to watch out for is that it is possible to have over 100 medals (though maybe not likely, but there are 302 medal events).  I would change the second formula to

      =gold + silver/1000 + bronze/1000000

      This will work for all medal counts (until they get up to 1000 medal events). 

      David 

  7. Stef@n says:

    sorry

    =gold + silver / 100  +   bronze / 10000

  8. Lisa says:

    Is there a VBA code if I need do same 3 layers customer sorting repetedly? 

  9. Mark says:

    I never thought sorting with multiple keys would be considered "custom sorting"...

  10. tadovn says:

    Hi all,
    Look like a sample logic for this:
    First thing, you sum all medal by category: example there are 10Gold, 50Silver, and 100Bronze in total.
    In this case, imagine you have 1 Silver, and I have 100 Bronze, your ranking is higher than me, so we can score: For you: 1*(100+1) (1silver *(100 +1) + 0Bronze, and me: 100 (0silver*(100+1) + 100 Bronze).
     
    For Gold medal, 1 medal is worth than every silver and bronze, so 1G>50silver*100Bronze, for sure, we can setup 1G=(50+1)silver*(100+1)Bronze.
    I checked for some example and saw that looks quite good.
     
    For general case, assume that total Silver is A, total Bronze is B (all country), your Score is: Gold*(A+1)*(B+1) + Silver*(B+1) + Bronze
     
    Looking for your comment,

  11. SomeintPhia says:

     
    Yes, I often use the custom sort, a great help.

    What would count more, 1 gold, 0 silver or 0 gold, 51 silvers? I could imagine, that still the gold will win.
      

    • tadovn says:

      Like you could calculate:
      For 1 Gold, 0 silver: score is 1*(51+1)*(0+1)+0*(0+1)+0=52
      For 0 Gold, 51 silvers: score is 0*(51+1)*(0+1)+51*(0+1)+0=51
      So the 1Gold is the winner.

  12. tadovn says:

    Hi all,
    After reading all comments, I got 2 solutions.
    First, using calculation, you could use the
    Infinitive number; the first comment of David, so you could easily remove all effect of Silver on Gold, of Bronze on Silver and Gold, the solution of Steph@n is on this logic.
    Or, you could use the Largest number; like the mine, I used the Total Bronzes and Total Silvers as Coefficient of Gold and Silver (read my comment).
    But I think the best is Clay's solution, use the Large enough number; in this case use the Max Bronze and Max Silver like the Coefficient, however, for Gold, using (Max Silver+1)*(Max Bronze+1) in place of (Max Silver+1)^2 is more logical.
     
    Second, on the idea of David, you could use Concatenate, ex, Gold as 1, Silver as 0. By this way, you have to setup for number of Silver and Bronze. The mine, I used =Rept("0",5-len(A2))&A2. Ex, if A2=1, it will be shown 00001, if A2=12, it is shown 00012. Normally, you will have a string like: 12100021000035 for 12 Golds, 21 Silvers and 35 Bronzes.
     
    Thanks for all comment and looking for others solutions,
     
     

  13. Shadow Jam says:

    Maybe its just me, but all this discussion on how to weight in so that the sort order is correct seems a little redundant.

    Whilst several news sources will indeed score purely on gold (which in the above example places Italy ahead of Russia even though they have over twice as many medals) this doesn't make it right.

    The Olympic committee do not recognise any country as winning, which therefore makes any weighting or ranking unofficial.

    I would suggest the best approach would be to shove it in a spreadsheet and  have the user decide the weighting. That way rather than just have a "gold always wins" approach, the user could say that two silver are equal to a gold, and two bronze a silver, or however they like.

    Personally I would say that with the two countries of Italy and Russia, to say that the one additional gold medal is worth more than 11 silver medals and 13 bronze, is a not only incorrect, but also disrespectful to the 24 athletes/teams who are still the 2nd and 3rd best in the whole world.

  14. Rushabh says:

    =CONCATENATE(REPT(Gold,4),REPT(Silver,2),G11)

    • Chandoo says:

      @Rushabh... interesting solution. Can you explain why this works?

    • tadovn says:

      When I tried with 2 cases:
      1G, 10S and 5B ->111110105
      2G, 6S and 6B -> 2222666
      On your way, this could turn to the rank of the first is higher than the second, in fact, it is reverse. That's right?

  15. Shadow Jam says:

    One simple option would be

    =Gold&"."&Silver&Bronze/10

    The decimal place deals with issues where a value >=10 could shift all the digits. The dividing the bronze by 10 ensures that when tied for gold and silver, 10 bronze would score ahead of 6 bronze.

    • Chandoo says:

      @Shadow... I doubt this will work. Assume two countries with 1 gold, 3 silver, 0 bronze and 1 gold 12 silver, 0 bronze. In your case, they will read,
      1.30
      1.120
      hence ranking 3 silvers above 12 silvers

    • tadovn says:

      @Shadow, it would be good enough if you control the length of number of Silvers and Bronzes.
      I always keep my treatment of string, and your formula will be totally working by:
       
      =Value(Gold&"."&Rept("0",5-len(Silvers))&Silvers&Rept("0",5-len(Bronzes))&Bronzes)
       
      @Chandoo, your cases are:
      1.00003 and 1.00012
      That's done.

  16. Shadow Jam says:

    Thank Tadovn.

    After a little bit of thought I could have done something very similar.

    =(Gold&":"&Silver&":"&Bronze)*1 

    by converting it into a time instead of a decimal, this correctly handles the variation in len. Providing the number of silvers or bronze does not exceed 59 then it works perfectly. Considering no one has more than 25 bronze or silver I would say its not a problem.

    It's no better than some of the approaches, but its always fun to learn a different way to cook an egg.

    • Chandoo says:

      Quite clever to use Time to deal with this.

      Another variation is to use years for gold, days for silver and seconds for bronze. This give you more freedom as maximum gold can be 8,099, silver can be 365 and bronze can be 86,400. You can use this for next few hundred olympics (unless China conquers US, UK & Russia, retains its sports competitiveness and convinces Olympic authorities to add a bunch of events).

  17. 123rgc says:

    Hi

    Some interesting posts on how to present the data.

    However, in presenting any data I think it's always good to see whether it could be presented in a different way to provide even more useful insight.

    For example, the Gold medal table takes no account of the relative population differences of the respective counties.  

    The USA leading the table  with 41 gold medals achieves this on a per capita basis of 1 gold for each 7.7m inhabitants. Hungary in 8th place with 8 medals achieved this on a capita basis of 1 gold for each 1.2m inhabitants, and would be ranked 1st per Capita.  

    Put another way the USA would have to get 252 gold medals to achieve the same per capita result as Hungary!

    For discussion, I have done a top 10 table and change chart with a link here:

    http://tinyurl.com/cxhruro 

    • David Onder says:

      The problem with the use of per capita is it does not directly relate to the number of competitors in the Olympics.  I would suggest using the number of athletes instead.

  18. Jacek says:

    Alternatively:
    =Rank(gold)*100+rank(silver)+rank(Bronze)*0.01

    Olympic medal table from 2012 in London is also available on:
    http://eexcel.co.uk/2012/06/30/london-2012-medal-table/

    Regards, Jacek

Leave a Reply