Implementing Python functionality
Just like R, TabPy makes use of the SCRIPT_
functions in Tableau. In the next sections, we will practice working with TabPy and will look at multiple use cases. Tableau calculations using TabPy look very similar to R’s. For TabPy, it is important to add a return
statement to the calculated field and notice that arguments are noted with an underscore instead of a dot:
Figure 15.31: Python TabPy syntax
This will be manifested in the next exercises; we will first investigate random number generators.
Random and random normal
Many calculations are easily accessible via the calculated fields, others via the table calculations—and then there are some hidden functions. Hidden because those are not (yet) fully supported or tested; therefore, use them with care. If you tried to find the function Random
, for example, you would not be able to. But you can still use the Random()
function, as can be seen here:
Figure...