It's pretty handy to be able to be able to see and analyze the Calculated Fields in your Workbooks without the tedious bother of manually inspecting them by opening up the Workbooks and looking at them one at a time. Even writing that sentence was boring.
Imagine how much better it would be to be able to use Tableau to see the Fields, all brought together so that they can be scanned, filtered, sorted, and otherwise freely investigated.
Here's a screen shot of a Tableau Worksheet showing the Calculated Fields from Tableau's Sample Workbooks.
Note: the data window and controls – shelves, filters, etc. have been hidden for clarity.
Tableau Tools makes it simple and easy to analyze the Calculated Fields in your Workbooks.
This post describes the basics of analyzing the Workbooks and accessing the generated CSV data files.
analyzeCalculatedFields.rbis a Ruby script that accesses Workbooks, locates the Calculated Fields, and records the information in CSV files.
It's self-contained, can be run as-is, and is available from GitHub here.
- Ruby is installed
- The twb gem is installed - normally via
> gem install twb
- analyzeCalculatedFields.rb is available at {path}
- The directory contains the Workbooks to analyze — we're using the Tableau Sample Workbooks here
> dir *.t* Volume in drive... Volume Serial Number is... Directory of {path}\Tableau Sample Workbooks 06/27/2018 10:32 PM 605,080 Regional.twbx 06/27/2018 10:32 PM 1,091,332 Superstore.twbx 06/27/2018 10:32 PM 533,181 World Indicators.twbx 3 File(s) 2,229,593 bytes
> ruby '{path}\analyzeCalculatedFields.rb'
As it runs analyzeCalculatedFields.rb provides information about its operation:
Twb::Analysis::CalculatedFieldsAnalyzer
Analyze Calculated Fields from Tableau Workbooks.
Processing Workbooks matching: '["*.twb", "*.twbx"]'
- Regional.twbx
- Superstore.twbx
- World Indicators.twbx
Analysis complete, identified
# of Workbooks : 3
# of Calculated Fields : 43
# of Referenced Fields : 84
For documentation and generated data see the following:
- ./ttdoc/TwbCalculatedFieldFormulaLines.csv Calculated fields and their formulas' individual lines.
- ./ttdoc/TwbCalculatedFields.csv Calculated fields and their formulas.
- ./ttdoc/TwbCalculatedFieldsReferenced.csv Calculated fields and the fields their formulas reference.
That's all, folks.
The CSV files can now be used to identify the Calculated Fields, their Formulas, the fields they reference, the Workbooks and Data Sources they are from.
The provided Tableau Workbook: 'Calculated Fields - Base Data.twbx' connects to each of the CSV files and has a
starter Worksheet for each, downloadable from here.
Another view of the Worksheet shown above is here:
Note: the data controls have been restored to show the more familiar Tableau user interface.
Data notes:
- As shown, formulas are available in two forms:
- as single elements, with all lines combined, and
- in their original lines as coded.
- "Formula Line #" is used to order the lines into their correct order, it can be hidden for clarity.
- The TwbCalculatedFieldFormulaLines data source is more generally useful than TwbCalculatedFields, although TwbCalculatedFields contains technical information about the calculated fields that is useful for advanced technical analysis.
Workbook notes:
- The Workbook is configured to pick up the CSV files from the current directory; this will be hard wired to whichever directory the Data Sources are using when the Workbook is saved.
- The Workbook is packaged simply to avoid GitHub from presenting it as XML text by default – this can be confusing to people who aren't aware of or used to seeing Workbooks as XML.
No comments:
Post a Comment