tableau / TabPy

Execute Python code on the fly and display results in Tableau visualizations:
https://tableau.github.io/TabPy/
MIT License
1.56k stars 598 forks source link

Using Tabpy Script Calls When Filtering #493

Closed alatterner closed 3 years ago

alatterner commented 3 years ago

Environment information:

Describe the issue So far, TabPy has been great and solves a tremendous need. I'm however running into issues utilizing python scripts in the filtering section of Tableau. I have a field that I'm comparing population numbers and running a chi squared test to figure out if the population is significantly different than a baseline population. I was able to get a correct p-value back and utilize that in various dashboards.

However, when I try to use one of these fields in a formula based conditional filter, it is saying that the variables are invalid. As a second attempt, I put the chi squared function call (wrapped in a script_real function) into the filter directly. The error then shows that script_real isn't found as a function.

For reference, this is when I put a variable in the "Filters" pane, right click it, and edit filter. I then use the condition --> By Formula section.

To Reproduce Attempt to use a SCRIPT_REAL function in the "filter -- condition -- by formula" section.

Expected behavior I expected that the tabpy scripts would be usable in a filter formula as is with the other functions.

Thanks so much. Sorry if this is obvious -- I haven't been able to find the information online to solve this.

nmannheimer commented 3 years ago

Hello @alatterner, unfortunately, table calculations (including SCRIPT_X calcs)cannot be used in the conditional/formula part of filters. You can filter on the table calculation directly, if you put it in the filter shelf and filter on the p-value. You could also write your filter logic into a calculation based on the table calculation, or into your python code itself. This means essentially that you will be filtering the view based on the output of the p-value and not filtering any other categorical fields directly.

Longer term, this kind of depth is something we are interested in developing.