Which of the following is the correct way to calculate Profit Ratio in Tableau?


Which of the following is the correct way to calculate Profit Ratio in Tableau?
A . Profit / Sales
B . Sales / Profit
C . SUM(Profit) / SUM(Sales)
D . SUM(Sales)/SUM(Profit)

Answer: C

Explanation:

THIS IS A VERY IMPORTANT QUESTION Aggregation is an important concept to consider when creating calculated fields. A calculated field for SUM([Profit]) / SUM([Sales]) will give you a very different answer than [Profit] / [Sales], even though both formulas are valid. If you do not provide the aggregation within the calculated field, Tableau will calculate the equation for every record ( row ) in your analysis, then aggregate the answers for all of the rows together when the calculated field is added to the view. In simple terms, if specify the aggregation such as SUM, what Tableau will do is that it will first calculate the sum of the Profit column ( say x ), then calculate the sum of the Sales column ( say y ), and then simply apply x/y —> This is what we expect! Perfect!

BUT, if you don’t specify the aggregation, it will go to every single ROW, perform Profit / Sales, and then aggregate the answers calculated for each row. This is simply NOT what we wan’t!

An example:

Reference: https://www.linkedin.com/pulse/tableau-tip-dont-make-error-ratio-calculations­bob-newstadt

Leave a Reply

Your email address will not be published.