- This article will explain how to calculate the percentage difference in Tableau with the following conditions:
- You should always calculate the percentage difference based on the first column
- Take the next available column into consideration if there is no value in the first column
- Formula to find % Difference = (Current Value - Previous Value)/Previous Value
- Step 1 Drag "Order Date" field to the filter shelf and choose current week.
- Step 2 Drag "Order Date" field to the coulmns, Right-click choose Exact date and then again right-click to choose Discrete.
- Step 3 Drag "Sub-Category" field to the rows.
- Step 4 Drag "Sales" field to the Text in Marks card.
- Step 5 Click on down arrow in the data pane and then select Create new calculated field. Name the calculation as "First Position Value".
- Step 6 Enter the following calculation in the "First Position Value"calculated field
WINDOW_MIN( IF NOT ISNULL(SUM([Sales])) then INDEX() END ) - INDEX() - Step 7 Create a new calculated field and name the calculation as "% Diff". Enter the following calculation
(SUM([Sales]) - LOOKUP(SUM([Sales]),[ First Position Value]))/ ABS(LOOKUP(SUM([Sales]),[ First Position Value])) - Step 8 Finally, drag "% Diff" calculation to the text, right-click and then choose Edit Table calculation to select "Table (Across)".