0
votes

I have a table with a lot of different columns in tableau. Each column has a calculated field.

I need to make about 15 more of these tables. Each one of these tables is nearly identical to the first, except that one flag is different in some fields, and other fields are named off of THOSE fields.

For example, I already have a table called "M Status now Active". Each calculated field is named "MSNA {field title}". Inside each calculation is something like "... AND status='active'"

How can I clone all of these fields, and the replace "MSNA" with another entry, such as "MSNI", and "active" with another entry, such as "Inactive"?

If I can figure out how to find and replace patterns in bulk, this will save me days of manually copying entries in Tableau.

All I want is to duplicate all fields which contain a certain pattern, but with a replaced version of that pattern. Like if I was using "sed".

Please help! When I look at a workbook in the filesystem, it is very hard to determine what I would have to modify.

I am very lost as to how I can do this in Tableau as I would if I were using any other technology.

Thanks!

1
Why not first try to make one parameterized visualization instead? Learn about parameters. Use them in your calculated fields. Let people change the parameter to adjust the view instead of tabbing to another (nearly identical) worksheet - Alex Blakemore

1 Answers

1
votes

I know this answer is a little late but:

All .twb files are essentially big XML documents. If you open up a .twb in a decent text editor (I use VS Code), you can manually create calculated fields in the batch-like manner you're looking for.

<column caption='Test Calc' datatype='boolean' name='[Calculation_1419478320962199552]' role='dimension' type='nominal'>
    <calculation class='tableau' formula='if [applicant_age] = &apos;15&apos; then true else false end' />
</column>
<column caption='Test Calc (Created in XML)' datatype='boolean' name='[Calculation_1419478320962199553]' role='dimension' type='nominal'>
    <calculation class='tableau' formula='if [applicant_age] = &apos;16&apos; then true else false end' />
</column>

Obviously there are a couple things to watch for. You have to escape special characters and also have to make sure that the 'name' attribute doesn't overlap with any other custom calculation you have since it's a unique identifier. When you open up your workbook again, your calculations will automatically be loaded and you can skip over doing it manually. I've done it a few times for usecases similar to yours!