7 Replies Latest reply on Nov 27, 2012 3:55 PM by Dimitri.B

    Help creating a random sampled input

    George Ricco

      Hey everybody!

       

        I just have a simple question. I've searched for a while on the forums and can't find the answers, and I know this has to be pretty easy.

       

        I have two fields, [Field_1] and [Field_2]. I'm graphing them as columns and rows, respectively.

       

        Now, I want to edit [Field_1], so that instead of using ALL values of [Field_1], the values displayed are a random sample of [Field_1] and only half of the values of [Field_1]. Maybe after that, I'd like to display 25% of the values of [Field_1] from a random sample.

       

        Any idea how to make this happen easily in Tableau?  I'll also take displaying every-other and every-every-every other value for [Field_1] if randomizing it and only taking half of the samples is too difficult.

       

        Also, I would *prefer* to do this by just creating a field, but I can't find the appropriate syntax to do this.

       

        Thank you in advance! Sorry for asking such a simple question.

        • 1. Re: Help creating a random sampled input
          Dimitri.B

          As far as I know, Tableau doesn't have built-in random number generator, and you can't create your own because Tableau doesn't support recursion.

          The only option I can think of is to add a column with uniformly distributed random numbers in data source, and use it with filters to show a portion of data.

          • 2. Re: Help creating a random sampled input
            Tracy Rodgers

            Hi George,

             

            Dimitri is correct in saying that there is no built-in random number generator--this would be need to be done within the data source. However, this might be a good one for the Ideas section!

             

            -Tracy

            1 of 1 people found this helpful
            • 3. Re: Help creating a random sampled input
              Alex Kerin

              Depending on your source (non MS JET), you may be able to do this with RawSQL:

               

              RAWSQL_REAL("RAND()") 

              1 of 1 people found this helpful
              • 4. Re: Help creating a random sampled input
                George Ricco

                Hey Alex,

                 

                  My source is just a simple, *.csv file. I actually have a random number column that I imported from the original data.

                 

                  I don't really know anything about SQL or how to implement the suggestion you're talking about. Is this a SQL script I would run upon connecting to SQL data?  Please elaborate for me if you would be so kind.

                 

                  (You know, Tableau would be so *&#^ed perfect if it just had a *few* more abilities. Coming from LISP (my strongest programming language,) and using IGOR Pro, I would probably stop using both LISP and IGOR Pro altogether if the data field functionality was a tad bit more robust).

                • 5. Re: Help creating a random sampled input
                  George Ricco

                  Hey Tracy,

                   

                    Thank you for the idea of bumping this to the ideas section.

                   

                    So here's a question about your response. When you say that the random number generator would need to be built into the source... I guess my question is how would I do this and have it update? Do you see what I'm getting at? If I have an *.excel file that I was linking to in Tableau and one column was just all =Rand() values, would Tableau be able to re-calculate that every time I connect to it? Or maybe I could issue a reconnect command? Does any of that remotely make sense? LOL!

                   

                    As I just mentioned to Alex, a few more functions in Tableau and I would throw out all of my other programs. The reason why I still use Igor Pro is because it handles large lists and has the most robust programming environment for large data structures I've ever used. (I am currently in a research lab where we have a data warehouse model and use SAS like mad. I have to use SPSS and a bit of Oracle with colleagues).

                  • 6. Re: Help creating a random sampled input
                    Alex Kerin

                    This would be a calculation that would add a column of data with a random number between 0 and 1 on each row. You can't use it however because csv files use the MS JET engine and rand() isn't supported.

                     

                    Your best bet is what you have done.

                    • 7. Re: Help creating a random sampled input
                      Dimitri.B

                      George Ricco wrote:

                      ...

                      If I have an *.excel file that I was linking to in Tableau and one column was just all =Rand() values, would Tableau be able to re-calculate that every time I connect to it? Or maybe I could issue a reconnect command? Does any of that remotely make sense? LOL!

                       

                      I don't know the precise mechanism of how Tableau does it, but the only way I managed to get new random values appear in Tableau Desktop connected live to Excel file with RAND() formulas was to re-calculate and save Excel file (F9 then Ctrl-S) and then refresh Tableau (F5).

                      If Excel file is closed, then refreshing Tableau or closing and re-opening it doesn't change anything.