Open hershey024 opened 2 years ago
Hey @hershey024 I'm able to reproduce your results if I create a parameter_dict
which defines filters that result in 0 data.
In my screenshot I'm doing this by setting an actual field to be filtered by a value which does not exist, which results in 0 results. Also in my screenshot is an example of a successful attempt, where the filters were performed on valid field/values and the result set returned actual data.
This suggests to me that your combination of filters may have at least one incorrect value. When a filter name
is incorrect, the API ignores that filter attempt (no harm done). But if your filter name
is correct and the values are not correct, this leads to a problem because the API passes the incorrect values through under the real filter field and no matching data is found.
My first guess would be that the area code might be incorrect. Is it possible you have aliased your area codes in Tableau? For example, I typically would see area codes like 303
in my own experience. Perhaps there is some aliasing in Tableau that maps 303
to XYZ
. If indeed the IND
area code maps to a number or some other value, then use the underlying "true" value rather than the alias. As for your dates, those seem fine. Still, it might be work saving your workbook as a .twb
file and then opening it in a text editor to see how your dates are stored and how various values appear in the workbook.
Here is a screenshot of my .twb
file opened in a text editor, where I've found how my dates are represented. In my case the appropriate way to specify my date filters would be in the yyyy-mm-dd
format (same as you have done) even though they render in the visuals as yyyy/mm/dd
. Ignore the #
symbol that wraps the value.
Hope that helps!
Hi @divinorum-webb, thanks for your help. I checked and changed the area code value and the filter is working fine, but the date filter is still throwing EmptyDataError. I entered the date in yyyy-mm-dd format. Also checked the underlying query to verify the original column name(changing to it) but with no luck. .twb file also displays the format in the same way above. Any further suggestions?
from tableau_api_lib import TableauServerConnection from tableau_api_lib.utils import querying, flatten_dict_column import pandas as pd from sqlalchemy import create_engine import urllib import io
Login through U/P, not using token
tableau_server_config = { 'tableau_dev' : { 'server': '', 'api_version': '3.14', 'username':'', 'password':'', 'site_name': '', 'site_url': '' } }
Date_filter = urllib.parse.quote('Ext Date') Month_filter = urllib.parse.quote('Relevant Month') Code = urllib.parse.quote('Area Code')
conn = TableauServerConnection(config_json = tableau_server_config, env = 'tableau_dev', ssl_verify = False) response = conn.sign_in()
response
Ext_Date = urllib.parse.quote("2022-07-04") Relevant_Month = urllib.parse.quote("2022-06-01") Area_Code = urllib.parse.quote("IND")
paramdict = { "Ext Date": f"vf{Date_filter}={ExtDate}", "Relevant Month": f"vf{Month_filter}={RelevantMonth}"}, "Area Code": f"vf{Code}={Area_Code}" }
views_df = querying.get_views_dataframe(conn) view_df = flatten_dict_column(views_df, keys = ["name", "id"], col_name="workbook") views_df.head(10)
views_df = views_df[views_df["workbook_name"] == "Month Results"] views_df_new = views_df[views_df["viewUrlName"] == "Results"]
views_df.head(10)
VIEW_ID = "6v2q12-baa4-3436-v2ws-aswdtgfcqagh"
views_name_df = querying.get_view_data_dataframe(conn, view_id=VIEW_ID, parameter_dict=param_dict)
views_name_df.head(10)
db_connect = create_engine('mqsql+mysqlconnector://----')