-
1. Re: How to automate renaming or aliasing column names
lenaic.ridinger Jan 18, 2017 7:27 AM (in response to NAVEEN KUMAR) -
2. Re: How to automate renaming or aliasing column names
Jim DehnerJan 18, 2017 8:19 AM (in response to NAVEEN KUMAR)
Yes this is possible (see the reference below) -
You create a secondary source that has the dimension name and its alias - Load the file as a secondary data source and create a relationship between the dimension name and its alias
Does that work for you?
Jim
Alias Field Values Using Data Blending
-
3. Re: How to automate renaming or aliasing column names
Yuriy FalJan 18, 2017 8:29 AM (in response to NAVEEN KUMAR)
Hi NAVEEN,
Tableau might want you to use Document API for this:
GitHub - tableau/document-api-python: Create and modify Tableau workbook and datasource files
Unfortunately, updating / renaming fields is not there (yet).
So you may want to work-around
by converting your Datasource table
into Custom SQL (HiveQL) Select statement.
Then you'd be able to replace rows in the code like this:
SELECT
...
[123] AS [123],
[456] AS [456],
...
to something like this:
SELECT
...
[123] AS [column_a],
[456] AS [column_b],
...
and so on.
This would be a one-time copy-paste operation --
as soon as your datasource table DDL doesn't change.
Hope this could help a bit.
Yours,
Yuri
-
4. Re: How to automate renaming or aliasing column names
Tom WJan 18, 2017 8:35 AM (in response to Jim Dehner)
1 of 1 people found this helpfulJim,
The proposed solution (relinking as above link didn't work - Edit Primary Aliases ) works to alias field values, not field names.
Naveen,
There isn't native support for such an operation in Tableau. You do have a couple of options though. They are all workarounds and each will require a different skill level.
Here's your options, I've ranked them from easiest to hardest based on my personal opinion:
- I'd recommend you just do this once and save / export your connection in Tableau so you don't have to do it again - Export Data Sources
- Create a view in hive where you alias the field names
- Use Custom SQL in Tableau to connect to the table and re-alias the field names.
- Create a script to edit the XML definition of your workbook / TDS file.
- This would be pretty straight forward with a scripting tool like Python, but it could even be achieved with VBA macros in Excel if you desired.
- Each column in your TDS would look like;
<column caption='123' datatype='string' name='[123]' role='dimension' type='nominal' />
you would need to change the caption to the friendly name so it looks like
<column caption='Column 1' datatype='string' name='[123]' role='dimension' type='nominal' />
- Look into using PIVOT / UNPIVOT functions in Hive. You could create a process where you unpivot all columns into a deep row structure, then you could join that to your table containing the field name definition and repivot it to a wide table using your new aliases. I've done this with MSSQL, I'm not even sure it's possible in Hive as I don't have Hive specific experience.
-
5. Re: How to automate renaming or aliasing column names
Jim DehnerJan 18, 2017 8:45 AM (in response to Tom W)
Thanks Tom -
My Bad -
I'm dealing with something similar and I think your comments will help
Jim
-
6. Re: How to automate renaming or aliasing column names
NAVEEN KUMAR Jan 18, 2017 9:18 AM (in response to Tom W)Thanks for your options Tom.
From your answers, second and third options are out of scope for me as they are not the candidates for automation ideally.
I am not sure how to solve my issue using your first option. Are you suggesting me to have export the SECOND DATA SOURCE? In that case, it would be same as Jim's option which doesn't fit for my case. Isn't it?
Appreciate your reponse.
Thanks
NAVEEN
-
7. Re: How to automate renaming or aliasing column names
Tom WJan 18, 2017 10:07 AM (in response to NAVEEN KUMAR)
My first option was that you connect via Tableau as you normally would, do all your renaming by hand then export the datasource. Next time you wish to connect, you open your saved datasource and all the aliasing is already done.
-
8. Re: How to automate renaming or aliasing column names
NAVEEN KUMAR Jan 18, 2017 12:58 PM (in response to Tom W)The idea is to automate Tom. Any future column alterations should automatically reflect in Tableau.
Anyways, really appreciate your response.
Thanks all