Saturday, June 17, 2023

What’s the point of a Fixed calculation in Tableau with example?

 The point of using a fixed calculation in Tableau is to perform calculations based on a specific scope or context that remains consistent, regardless of the level of detail in the visualization. Let's consider an example to understand the point of a fixed calculation:


Suppose you have a dataset of sales transactions that includes the following dimensions: Region, Category, Sub-Category, and Sales Amount. You want to calculate the percentage of sales for each sub-category within its respective category. However, you want this percentage to be based on the total sales of each category, regardless of the level of detail in the visualization.


Here's how you can use a fixed calculation to achieve this:


1.Create a fixed calculation:


  • Go to the Analysis menu, select "Create Calculated Field".
  • Name the calculation "Percentage of Sales by Category".
  • Enter the following formula:

            SUM([Sales Amount]) / SUM({FIXED [Category] : SUM([Sales Amount])})

  • Click OK to create the fixed calculation.


2.Use the fixed calculation in the visualization:


  • Drag the Sub-Category dimension to the Rows shelf.
  • Drag the newly created "Percentage of Sales by Category" calculation to the Columns shelf.
  • Drag the Category dimension to the Color or Label shelf to distinguish different categories.
  • You can also include other dimensions or filters as needed.


The result of this fixed calculation will be the percentage of sales for each sub-category, based on the total sales of its respective category. This calculation ignores the level of detail in the visualization, providing consistent and accurate percentages based on the defined scope.


The benefit of using a fixed calculation in this example is that it ensures the percentages are based on the total sales of each category, regardless of any filtering or drill-down actions performed by the user. It provides a fixed context for the calculation, allowing for accurate analysis and comparison of sub-category sales within their respective categories.


Without the fixed calculation, the percentages would be calculated dynamically based on the current level of detail in the visualization, which might lead to inconsistent or misleading results.


In summary, the point of using a fixed calculation in Tableau, as demonstrated in this example, is to define a specific context or scope for calculations that remains consistent and unaffected by the level of detail in the visualization.

No comments:

Post a Comment

If you have any doubts. Please let me know

How can you create an alias for a table in a SQL query?

In SQL, you can create an alias for a table in a query to give the table a temporary, alternative name that you can use in the query. Table ...