What happens if you run this code while monitoring your TabPy console (curious to make sure that the list comprehension is making the right list):
from scipy.stats import linregress
slope, intercept, r_value, p_value, std_err = linregress(_arg1, _arg2)
print([slope*x + intercept for x in _arg1])
", SUM([Revenue ($)]), SUM([Units Sold]))
The results should look like a list of length len(Sum(revenue)).
One thing to check it that the table calculation is set to address all fields.
the above code only returns 1
the original print statement didn't work
The print statement should print in the command line where you are running TabPy. This print out should confirm whether the results are formatted correctly or there is an issue with. Looking at similar situations where people have encountered this error, it is likely due to the way the table calculation is computed. You want to make sure that everything is on addressing so that the calculation runs on the full dataset. If it runs on one point at a time it will be undefined. The table calculation dialogue should look like this if you (for example) used Product Name as the level of detail in the visualization:
I've attached a working example here!
Working Function.twbx 426.3 KB