Pivoting rows to columns
In this section, we will explore pivoting rows to columns. There are instances when our data sources have multiple, conditional fields contained in the same column. This structure of data will cause problems because Tableau likes every column to be a unique field. If we look at the structure of our Bad Measures.xlsx
file, as shown in Figure 5.7, you can see that there is a column called Measure and another column called Value. The ideal data structure would have four columns, one for the date and one each for sales, profit, and volume:
Figure 5.7 – The Bad Measures file
If we don’t pivot these rows to columns, analysts using Tableau Desktop don’t have an easy way to create views and dashboards in Tableau. The best they could hope for is to create three calculated fields, one for each of the measures, as shown in Figure 5.8:
Figure 5.8 – Result of calculated fields
This approach...