

























Posted by on January 6, 2015
You want to do some visualisation magic in Tableau, but your spreadsheet looks like this:
All those green columns are dependent variables: independent observations about one location defined by the white columns.
Tableau would be so much happier if your spreadsheet looked like this:
This is called “normalizing” the “cross-tab” format, or converting from “wide format” to “long format”, or “UNPIVOT“. Tableau provides an Excel plugin for reshaping data. Unfortunately, if you don’t use Excel, you’re stuck. It’s kind of weird.
Anyway, I’ve made a Google Sheets script “Normalize cross-tab” that will do it for you.
As the instructions say, to use it, you:
It then creates a new sheet, “NormalizedResult”, and puts the result there.
It’s surprisingly clumsy to share Google Scripts, at least until the new “Add-ons” feature is mature. Here’s the best I can do for you:
Go to https://raw.githubusercontent.com/stevage/normalize-crosstab/master/normalizeCrossTab.gs, select all the text, and copy to the clipboard.
Upload your Excel spreadsheet into Google Sheets, if it’s not there already.


In the window labelled “Code.gs”, select all the text and paste over it the script from the clipboard.

You need to give this script “project” a name. It doesn’t matter.



Click Continue and accept the authorisation request.

Now, switch windows to your Google Sheet, and you’ll see the sidebar.

On the NormalizedResult page, choose File > Download as…
If you want to convert several spreadsheets, you can save yourself pain by loading them all into the same workbook. Just remember that the script will always save its output to NormalizedOutput.
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。