Skip to main content

Created a function in Python to return value based on the comparison.

If I am calling it from Python it is returning the result as expected.

But when I am passing the value from Tableau with Tabpy if comparison not working telling no return value.

Would it possible to get some guidance on it

Attaching the code

Python function

def my_function(X):

    with open("C:\Arijit\Arijit\TGF\Tab_PI\Datedim1.csv", "r") as csv_file:

        csv_reader = csv.reader(csv_file, delimiter=',')

        i=0

        df =[]

        for lines in csv_reader:

            df.insert(i,lines)

            i=i+1

        for j in df:

            ##if datetime.strptime(X, '%d-%m-%Y').date() == datetime.strptime(j[0], '%d-%m-%Y').date():

                if X == int(j[0]):

                    return(int(j[1]))

                 

Tableau function

     SCRIPT_INT("return tabpy.query('testfunc',_arg1)['response']",attr([demodate]))

1 answer
  1. Nov 29, 2020, 7:06 AM

    Please attach your packaged workbook (twbx) so that any solution suggested is relevant and works for you.

0/9000