Wednesday 15 September 2021

Running Python Scripts from Tableau Desktop

 

Tableau can pass code to TabPy through one of four different functions: SCRIPT_INT, SCRIPT_REAL, SCRIPT_STR and SCRIPT_BOOL. Each of these accommodates a different return type.


Exercise:-

In Tableau Desktop, Connect to the SuperStore sample dataset


ü  Create a calculated field by selecting the Analysis menu / Create a Calculated Field…

ü  Name this new calculation as  "City State" and with below Formula


SCRIPT_STR("

print(_arg1)

print(_arg2)

 

lst=[]

for i in range(0,len(_arg1)):

  lst.append(_arg1[i]+', '+_arg2[i])

return lst

",

ATTR([City]),ATTR([State])

)



ü  Create a New worksheet and Drag:

 year of Order Date to columns.

Region to Rows,

Sales to rows.


Drag the calculated field "City State" to color.




Check the result of the "City State" calculation in the tooltip.



Thanks Guru's,
Prazwal Ks

DAX Time Intelligence Functions

   Thanks Guru's, Prazval.Ks