1 2 Previous Next 25 Replies Latest reply on Jun 22, 2016 5:15 PM by Ivan Young

    Aggregate Top N measures per Player

    Vivek Nallapaneni

      Hey everyone!

       

      I'm new to the Tableau community but a Tableau user at work for a year now.  I've used these forums over the past year to answer a ton of my questions.  I have run into a problem that I'm hoping to solve with your help.  I haven't found the answer through my search. 

       

      I currently have a data set of sports players, their games by game date(and game ID) and their statistics at the game level.  See example below.  What I'm looking to do in Tableau is to provide a summary of the statistics for each player for the last N of their games played.  So lets say I want to the last 3 games for each player.  So the output should look like the example below.  I've tried using the Index() and Rank() functions but once I start to introduce the measures(Points, Rebounds, Assists) the rank or index change and I can't find the right combination with table calculations.  The part that seems to be difficult is that the Game Dates will be different for each player when looking at last N.  As you can see, Lebron has played more recently than Kobe, so I want the numbers from his last 3 games, which are in June, AND Kobe's last 3 games, which are in May.  This N needs to be dynamic as selected by the user.  They may want the last 3 games, or 10 or 20, etc. 

       

      Example Output:

      Player | # of Games | Points | Rebounds | Assists

      Lebron          3              94             27             24

      Bryant           3              84             14             11

       

      Example:

      Player | Game ID | Game Date | Points | Rebounds | AssistsLebron  6172016    6/17/2016       30             7              10

      Lebron  6122016    6/12/2016       24            10              8

      Lebron  6052016    6/05/2016       40            10              6

      Lebron  6012016    6/01/2016       21            9                8

      Lebron  5122016    5/12/2016       32            7                9

      Bryant   5122016    5/12/2016       30             7              4

      Bryant   5072016    5/07/2016       34             4              5

      Bryant   5052016    5/05/2016       20             3              2

      Bryant   5012016    5/01/2016       21            9                8

      Bryant   4122016    4/12/2016       32            7                9

       

      Appreciate the help!

        1 2 Previous Next