2 Replies Latest reply on Dec 20, 2017 9:03 AM by Robert Maroney

    Get N random records

    james.n

      I created a program that counts points associated with people.  Each person is associated with a location.  I have no problem identifying the top N records (highest point count per location).  This is shown in my attachment, on the first worksheet - "Awarded Points".

       

      Now I want to play a game with the participants. In this case, imagine horse racing.  (My program is educational.  I call this Course Racing.)  I want Tableau to select eight random people from one selected location.   (I have a parameter filtering the locations.  This is not in my example.)   The names and some basic stats will be shown on a LED display linked to a Tableau view.  I've simplified this on a worksheet called "Led Board".

      On my example, there's a worksheet with a random number calculated field.  Refreshing the data source will refresh the random number column.  My first issue is applying a rank to the list.  I can't get the Table Calculation to sort the list according to the random numbers.  Lowest to highest or vice versa...doesn't matter.  I just want 8 random people.

      Assuming we can identify the users, my next issue will be figuring out how to do it on the Led Board.

       

      I can do all this on the SQL side, outside of Tableau...via a stored procedure to pull eight members.   But I'd like to identify a Tableau solution.

        • 1. Re: Get N random records
          Mark Fraser

          Hi James

           

          There is a lot of detail in your question (you obviously know your way around Tableau) and I have to admit I'm not sure if I have followed everything.

          Anyway, I'm messaging because I'm not sure if you're aware you can generate random numbers in Tableau.

          There is a random function its not listed in the functions (don't know why?!) but it's there...

          Maybe that little nugget helps

          Best of luck!

           

          Cheers

          Mark

          • 2. Re: Get N random records
            Robert Maroney

            Hi James - Any luck with this question? I am running into a similar problem.