This issue is occurring because the entire JSON object is getting returned to Tableau. You need to pull the response field out of the object to see the correct values. When querying a deployed endpoint, the syntax should look like this (which should fix your issue):
Were you able to get this working?
I recently successfully installed Tabpy and used your example to test how it works.
I ran into error message says:
"Unable to complete action
Unexpected number of results returned by SCRIPT function. Function expected 3 values; 6 values were returned."
What did I do wrong?
Any help appreciated!
In your case here, your function is directly adding _arg1 and _arg2. However, when these arguments are passed from Tableau they are Python lists, not integers, so your code is essentially concatenating the two lists of length 3 together into a list of length 6, which is causing the error. Tableau is returning the combined list which is length 6 and trying to read the six items out of it, which don't match the length of the lists passed (3).
You just need to write your code to handle the incoming variables as lists, for example using np.add(_arg1,_arg2).
Thanks for the feedback!
I finally got it working! Here listed all 3 methods and results I had. Might be helpful to others at some point.
A few takeaways:
- SCRIPT_REAL/SCRIPT_STR decided the returned value type. The python code need to be written to return same data type
- After add calculated fields to dashboard, "Edit Table Calculation" maybe needed. In my example here, need to use "Compute Using -- Pane (Down)"