Automate the tedious process of creating user filters in Tableau, simply by converting between XML and CSV formats.
Important Please ensure you have a backup of your Tableau workbook before making any changes. If you have questions, please open an issue in this repository.
๐ฅ Watch the introductory video on YouTube.
Tableau User Filter Automation
requires Python 3.6 or higher. If you don't have Python installed, you can download it from here.
After you've installed Python, you can set up the Tableau User Filter Automation by following these steps:
git clone https://github.com/YourUsername/TableauUserFilterAutomation.git
cd TableauUserFilterAutomation
# Install requirements (if any)
pip install -r requirements.txt
No additional libraries are required as the scripts use Python's standard libraries.
-
Open your Tableau workbook (.twb file) in a text editor
-
Locate the user filter XML section and save it as
access.xml
-
Run the XML to CSV script:
python xml_to_csv_script.py
-
Find the resulting CSV file at
output.csv
-
Prepare your CSV file with user permissions data (use
output.csv
as a template) -
Run the CSV to XML script:
python csv_to_xml_script.py
-
Find the resulting XML file at
testaccess.xml
-
Copy the generated XML and paste it back into your Tableau workbook file, replacing the original user filter XML snippet
The CSV file should have the following structure:
Member,Set1,Set2
user1,Permission1,Permission2
user2,Permission3,Permission4
The XML format follows Tableau's structure for user filters. The script will handle the specific formatting required by Tableau, including namespaces and special characters.
You need to customize the following variables in the csvtoxml.py script to match your Tableau workbook's configuration:
- In the CSV to XML script, modify these variables to match your Tableau workbook's configuration:
# Step 1: Change the name of your user filter here e.g. [User-Filter-1]
filter_name = "[your-user-filter-name]"
# Step 2: Change this to your domain eg. external
your_domain = "your-server-name"
# Step 3: Change this to your variable name e.g. [City]
secondary_group_level = "[your-variable-name]"
Additional variables you may want to adjust
primary_group_function = "intersection"
secondary_group_function = "level-members"
- Ensure your input files are correctly formatted and located in the same directory as the scripts.
- Check that the file paths in the scripts match your actual file names.
- If you encounter XML parsing errors, make sure your Tableau workbook XML is well-formed and doesn't contain any special characters that might interfere with parsing.
For any additional issues or questions, please open an issue in this repository.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.