KNOWLEDGE BASE

How to filter by item numbers for each date by descending order


Published: 06 Mar 2023
Last Modified Date: 06 Mar 2023

Question

How to filter by item numbers for each date by descending order:
Before: (some items are disappeared/filtered)
User-added image
After: (each item is filtered by 2 and following the latest/newest date)
User-added image

Environment

  • Tableau Desktop 2022.4.1
  • Windows Server 2019
  • PostgreSQL

Answer

1. Create a parameter: int> 1
2. Create a calculated field:
Name: [TS]show_item_number
Value: -(RUNNING_SUM(COUNTD(DATETRUNC('day', [Date])))-WINDOW_COUNT(COUNT(DATETRUNC('day', [Date]))))+1<=[show_item_number]
3. Drag the filter to the filter card.
4. Edit the table calculation in the filter card: specific dimensions> choose [product name] and [date] only.
5. Show the parameter, and change the number to check the view.
See the file attached sample workbook for details.
Did this article resolve the issue?