6 Replies Latest reply on May 16, 2018 5:18 PM by Peter Fakan

    How to get static random number?

    Julia Tran

      Hello, I am hoping someone could let me know how I can assign a random number between 0 and 1 to each of my raw data rows, and have the random number remain static.  Is this possible in Tableau?  In Excel, I would use the random function, then copy and paste as value to keep the numbers static.  Right now, in Tableau, the random values are recalculating every time I change calculations in the sheet.

       

      I am using Tableau 10.5.2, but I do have Tableau 2018 as well.  Just haven't installed it yet.

       

      Thanks for any pointers,

      Julia

        • 1. Re: How to get static random number?
          patrick.byrne.0

          Hello Julia,

           

          This is a very interesting scenario and use case for Tableau. In the given scenario the numbers are going to recalculate every time the viz is updated as you have seen. Because every time that column is used the RAND() will be enacted. There is not a currently a way to prevent this from updating without simply preventing the whole workbook from updating. Which if there are changes being made to the Viz it will need to update to render properly.

           

          One workaround would be to create the randomized number column in the data source itself. That way it would be static and reusable.

           

          Cheers,

          Byrne, Patrick

          • 2. Re: How to get static random number?
            Jim Dehner

            Hi Patrick    

            Interesting thought - how would that work to fix a random value for use in other calculations

             

            I think it is important to note here that excel recalculates the random number every time it does a refresh also and the process of copying and pasting a value is like an electronic scratch pad -

             

            Jim

            • 3. Re: How to get static random number?
              patrick.byrne.0

              Sorry if I was unclear. I mean, by generating the randomized column, then inserting just the values as a column into the data source as just values. So not really random I guess. But as you mentioned I believe using any sort of random function will cause the values to change anytime the data is modified.

               

              Cheers,

              Byrne, Patrick

              • 4. Re: How to get static random number?
                Jim Dehner

                OK I get it - I guess if you did that you could also have a parameter (sequential) and use it as a pointer to a random number from the list - the user could then increment the "pointer" or hold it "Fixed" or to recall history?  as long as the column of numbers is random I think the effect is still random

                 

                JIm

                • 5. Re: How to get static random number?
                  Gerardo Varela

                  Hi All,

                    I'm not sure i'm following the full use case but I'm hoping this at least sparks some ideas:

                   

                  Random Numbers (Even with Extracts) | VizPainter

                   

                  So from the example above something to the sort of:

                   

                  (((PREVIOUS_VALUE(MIN(327680)) * 1140671485 + 12820163) % (2^24)))

                  *.00000001

                   

                  That should provide sudo random values from 0 to 1. 

                   

                  Regards,

                  Gerardo

                  • 6. Re: How to get static random number?
                    Peter Fakan

                    Once you calculate your random numbers, extract the data and re-ingest it into Tableau - viola your random numbers are now static.

                     

                    HTH

                     

                    Peter

                    1 of 1 people found this helpful