Filter a View, not the underlying data

Filter the View, Not the Underlying Data

Sometimes you want to hide data from the view but still use the data in calculations. Tableau “Table Calculations” filter the view, but don’t filter the underlying data.


Introduction

In this example, I create a calculated field that uses a Lookup() table calculation. I’ll use the new calculated field on the Filters shelf to filter the view.

I created a second table calculation for a moving average calculation that uses data from the previous year which is not showing on the view.

If you download the sample Tableau file from Tableau Public, it already has the “Average” view with “Order Date” on the Rows shelf and “Sales” on the Text tile on the Marks card.


Project Files

Tableau Public file

Preview - the Finished Chart

For the first example, I am creating a simple text chart.

Dashboard with Moving Average Charts

Data & Fields

This chart is based on the Sample Superstore data source and utilizes these fields.

The data type for “Sales” is a “Number (decimal).” In this view, “Sales” is a continuous field on the Text tile of the Marks card. Initially, the aggregation is “Avg” on the first visualization, and I changed it to a “Moving Average” table calculation on the other two visualizations. Because the field is on the Text tile, Tableau creates a traditional “Text” chart that looks like a spreadsheet.


Order Date

For the “Order Date” field, I choose the Date Level “Date Value” and “Month.”

I chose a “Date Value” and checked "discrete." The field is blue on the Rows shelf.


Create the Viz

Download the sample file from Tableau Public or recreate the “Average” view with the two fields as outlined above.

1. Create a copy of the “Average” view.

2. Change the title for the new sheet to “Moving Average.” Right-click on the sheet tab along the bottom of the screen and select “Rename.”

3. On the Marks card, change the “Avg” calculation to a table calculation, “Moving Average.” Right-click on the field name and select “Quick Table Calculation” from the drop-down context menu. Next, select “Moving Average.”

4. Create a copy of the new “Moving Average” sheet.

5. Update the title for the new sheet to “Filtered Moving Average.”

6. Create a new calculated field “Date Lookup Filter.” In the Data pane on the left, click on the drop-down arrow to open the context menu and select “Create Calculated Field.” In the calculation editor enter the formula.

7. In the Data pane, right-click the new “Date Lookup Filter” field and select “Convert to Continuous.”

8. Drag the new field “Date Lookup Filter” to the Filters shelf.

9. In the filter dialog box use the slider to select only 2023 dates. Click on OK. Because this is a continuous field, the filter has a slider for the date range.

10. Create a new dashboard and add the new charts to the dashboard view. In the bottom right corner click on the dashboard icon to create a dashboard. If you hover your mouse over the icons, a tooltip appears with the icon name.

In the new dashboard view, drag the sheets from the left “Dashboard” pane in the middle “Sheets” section and drop the sheet onto the dashboard view. A gray box indicates where the view will be added.


Thank you for reading! If you have questions or comments, you can reach me at cryoung6@att.net