• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to Rank Data Based on Number of Appearances and Rank in a Given Worksheet

JRock

New Member
I currently create a weekly top 10 list for an internet radio station (each week gets it's own worksheet). I have created rank, and tie break formula's within the worksheets. At the end of the year I want to rank the artists/songs based upon the length of time they spent on our "chart" and their average rank during that time period. Is there a formula that will cull the data, and list the songs in the correct order?

Example: Week 1 (Worksheet title "January 23rd")
Band Song Final Rank
Nonpoint Breaking Skin 2

Week 8 (Worksheet title "March 20th")
Band Song Final Rank
Nonpoint Breaking Skin 7

Each week from Jan 23rd - March 20th this song had a rank between 2 and 7. It spent a total of 9 weeks on the chart. Based on its performance against competitors over the same time period I need to know where it falls in a final ranking of the top 100 songs of the year. Is there a formula or a combination of formulas that will accomplish this task for me.

Thank You,
JRock
 
Hi JRock, and welcome to the forum.

So, we can't do just a straight average of the rank, because a song that was #1 for 2 weeks should be better than a song that was #1 for just 1 week. So somehow, we need to have each week be weighted into the score.

With the idea, here's my proposal:
Let's say that each week, a song can earn somewhere from 100 to 1 point, 100 pts being for being #1. So, if you were #1 for 2 weeks, you earned 200 pts, and if you were #2 for 3 weeks you earn (99+99+99=297 pts). Sound like a fair methodology?

If so, then Assuming your raw data looks something like:
Name of Song | Rank
Lucky | #3
Punk | #4
Lucky | #2
etc., and then somewhere else you had a list of all the songs, we can use a SUMPRODUCT formula like:
=SUMPRODUCT(101-(NameRange=SongName)*(RankRange))
and then rank the scores to determine the overall #1 song. The attached may help illustrate better.
 

Attachments

  • Song Ranks.xlsx
    8.8 KB · Views: 2
Luke,

Thank you for your prompt response. I had my original file emailed to me for you to peruse. You will get a better idea of what I am doing. I like your idea to rank the songs based upon their time in position. Will excel pull a list of the songs from my workbook so that I do not have to go through and retype the list or should I start typing it now in an effort to avoid a massive undertaking at the end of the year? As you can see many of the songs will repeat and we only get 1 or two new offerings each week (in most cases).
I am not a total excel idiot but I watched a YouTube video, repeatedly, in order to get the formula right for the rank and tie-breaks. Also keep in mind the bottom chart is just a visual representation of the previous weeks ranking just for quick reference. The good formulas are in the top.

Thank You Again,
 

Attachments

  • By Week Top 10.xlsx
    153.2 KB · Views: 1
Few questions:

Which column(s) of the file are we looking at to give us the rank? Is it just col D, the charts, or is it col P, the average of several things?

Just rememberd that you said your data is spread across multiple sheets...ugh. We probably want to use this macro to get everything onto a single sheet. Don't mind the layout/sheet name too much just yet, we can work on changing that in a bit.

Getting all our data into a single sheet is pretty much a requirement to do any type of analysis.

Once it's in place, build a Pivot, and we can analyse. Here's what I've got so far.
One thing that pops out at first is that we've got "bad data". Check out the highlighted cells on Sheet pivot. These should be the same, but there's slight differences in the source. B5 is missing an apostrophe, A31 has an extra space. This will throw off our calculations, so we will want to go back and fix those in original data (the weekly sheets). You'll see that the file already has the macro in place to merge the data together, and build the summary sheet.

Hopefully this shows the rough idea well. Based on given data, Moth by Hell Yeah would be the #1 overall song. I wasn't sure if you wanted just Album, Band, or Band + Album.
 

Attachments

  • Song Ranks.xlsm
    213.9 KB · Views: 0
Luke,

I must say this is way over my head. I understand the need to correct the data to prevent duplicate band listings. I can also see why you merged the sheets together in order to be able to analyze data. What I am missing is the how. I have never seen a pivot table before and I am not sure where the "score" formula came from "21-O2" etc...etc...(particularly the number 21) on the RDBMergeSheet. I can tell you that the ranking will be based on col R, the final rank. It will be set up as band + album (of course that should be song not album I just didn't change it yet, I guess I am a little behind the power curve but, better to start now for a big show in December than wait until the last minute right?).

I am so grateful to you for taking the time to look at this. I just need to understand it because I will have to do it again next year.

Thanks Again
Jeremy
 
Hi Jeremy,

Not a problem, i'll try to break things down.

PivotTables
First, a PivotTable is a analysis tool within XL. It's meant to take a block of data and allow you to filter/compare different fields pretty easily. One nice things is that it supports drag-and-drop type behavior, so if you have something in the column area, but want it in the rows, it's fairly easy to move. A basic introduction to setting up a PivotTable can be found here:
http://www.contextures.com/CreatePivotTable.html

Our File
In the file I sent you, on the Pivot Worksheet, you can (hopefully) see the PT which has the Band and Album fields, and then the score. To get a true "top 20", if might help to remove the Band field (can drag it out of the way, or use the Field List on right of screen), and if we sort Album then descending by score, we'll have a list like:
upload_2015-4-30_8-43-28.png
which I think is our end goal.


Now, how did we get there?
As I said, merging the data into a single location is pretty much critical. You could do it manually, but neither you nor I have time to do that, so let's let the lazy computer do it for us via a macro, eh? :p As I'm a lazy programmer, I used the code from here:
http://www.rondebruin.nl/win/s3/win002.htm
which was a pre-built macro that I was able to use. Not to get into inner workings, but basically it scans through all the sheets and copies a pre-defined range. The one important part of the code you might need to change is about half-way down, and looks like this:
Code:
            'Fill in the range that you want to copy
            Set CopyRng = sh.Range("A5:O24")
This is where I told the macro what range to copy. With your workbook, the score of interest I thought was col O, hence why I only went that far. In the attached, I ammend that to grab all the way to col R so we can get the Rank.

Now that we have the data all merged, we want to calculate the score per the idea I proposed in my first post above, where a rank 1 gets the most "points". Since we only have 20 songs each week, the rank 1 song gets 20 points, rank 20 song gets 1 point. In the DoItAll macro, you'll see this line
Code:
    'Song list is a Top 20, so subtract from 21
    .Range("S2:S" & LastRow(ws)).FormulaR1C1 = "=21-RC[-1]"
Not to get hung up in the mechanics of the code, but it's basically saying to put a formula in col S that does
=21-R2

It's a little confusing because formula uses what's known as RC notation (row/column), but most of us use A1 notation (columns = letters, rows = numbers). Anyway, that gives us the score we want. The PivotTable is then able to grab that field, and do our analysis.

How to use for future use?
Assuming that your data keeps coming to you in multiple sheets, you can use the macro in the file already, or merge it manually. Either way is fine. If using the macro, the onle thing to pay attention to, as noted above, is the range to copy, and all the sheets should have identical layout. If one sheet had an extra column inserted, this would mess things up.
Once the data is all merged, again, you can do what you want, but the PivotTable in this file is already setup to look at the RDBMergeSheet. right-click on the PT, and hit refresh, and it will load in the new data, and you should be good to go.

Looking up, that was a lot of text, so take a read through and let me know what questions you have. :) We're here to help you learn. :awesome:
 

Attachments

  • Song Ranks2.xlsm
    219.4 KB · Views: 3
Luke,

Again thank you so much. I will take a look at this as soon as my life gives me about an hour to sit down and study it.

Thanks,
Jeremy
 
Back
Top