Occasionally, you will find the need to compare filtered data against the total data source. As Tableau’s filters remove the data from the data partition, this can sometimes be a tricky problem.
You might be tempted to try the “Total” function in a formula like the following:
TOTAL(SUM([Sales]))
As you will quickly discover, since the filters removed the filtered results from the data source, this does not return the graph you’d expect it to and you end up with an interesting, but useless, chart.
By duplicating your data source and joining on it, you can bypass this problem. In the join, instead of joining logically, you will need to join on something fairly arbitrary, such as “Ship Date” in the SuperStore data. If I had joined on “Region”, I would have the same problem, as the “Region” field in the new data set would also become filtered.
After you have the join setup correctly, simply pull in the “Sales” field from the joined data source and edit aliases as needed.
In my case, I changed the new field to “WW Sales”, but if you’d like to compare against only “United States” sales, you can do so by simply creating a secondary filter on the new data.
Note: In this example, my results are fairly simple and can also be achieved using other methods. If possible, use the built in “analysis -> totals” functionality, parameters, or calculated fields instead of a self join. In many cases, however, these alternatives are not possible and this solution is needed.