Filters can cause problems when using table calculations in Tableau. Here’s a trick to use a filter while also using table calculations. We’ll use the lookup function to force the filter to be applied after all other calculations.
![](https://ynteractive.com/wp-content/uploads/2023/02/c8bad1_1a3a40594fee434687caab34dc6f4cc1mv2.png)
Step 1:
Build a line chart using Month([Date]) and sum([Sales])
![](https://ynteractive.com/wp-content/uploads/2023/02/c8bad1_7d520de0c62c4c26bfd4d023a1f4efdcmv2.png)
Step 2:
Copy the sales pill, and add a quick table calculation; Percent Difference
![](https://ynteractive.com/wp-content/uploads/2023/02/c8bad1_12a38a1b4a7147ef851ab035fd7d4444mv2.png)
Step 3:
Add a filter for the year 2020 only. The data is now filtered to 2020, but January is missing a percent difference value. The table calculation will not work when data is filtered out.
![](https://ynteractive.com/wp-content/uploads/2023/02/c8bad1_33914983951b41e59f1243281cfccfd9mv2.png)
Step 4:
In order to avoid the filter, use the lookup function to create a filter as a table calculation instead. Now, the filter will be applied after the percent difference is calculated.
lookup(max(DATEPART(‘year’, [Order Date])),0)
![](https://ynteractive.com/wp-content/uploads/2023/02/c8bad1_2d1285f891ef48fa86ca379656fac071mv2.png)
Step 6:
Convert the new filter to discrete and drag it to the filter shelf. Now, January is displaying a value.
![](https://ynteractive.com/wp-content/uploads/2023/02/c8bad1_e5f575fc6c37431ba54d7b2014bb7a02mv2.png)