One of the most common type of measures is the percentage of a value within a population. Tableau provides options for converting values in a row or column to fractions of row or column totals; however, we can also create new fields with some calculated values presented as percentages.
Let's use the sample file Sample – Superstore Sales (Excel)
. Open a new worksheet and select Sample – Superstore Sales (Excel) as the data source.
Once the data is loaded on the worksheet, perform the following steps to create a new calculated field:
My Profit Ratio
.sum([Profit])/sum([Sales])
as shown in the following screenshot:In the calculated field, we aggregated the Profit and Sales fields before dividing them. By calculating this way, we summed the Profit and Sales fields individually and then performed the division. This is different from dividing profit and sales first and then summing those values—this type of operation is a row-level operation and is suitable for many occasions. However, we have to remember to aggregate fields to avoid unexpected results.