KNOWLEDGE BASE

How To Show Most Recent Label When There Are No Time Or Date Type Field In The View


Published: 30 Mar 2020
Last Modified Date: 04 Jun 2020

Question

Label the most recent marks in the view. When there is a time or date field in the view, you can label all marks that correspond to the most recent date or time in the view. When you select this option, you can specify a scope for the labels in the view.

For a view without a time or date field, you can't select the Most recent label.
User-added image

Environment

  • Tableau Desktop

Answer

  1. Create a parameter calls select a date unit
  2. Create a calculation field like below and name it week or month
    if [select a date unit] = 1
    then 
    DATEPART('week',[Order Date])
    ELSEif [select a date unit] = 2
    then 
    DATEPART('month',[Order Date])
    END
  3. Create a calculation field like below and name it most recent label 
    if [select a date unit] = 1 then 
        if [week or month] = {fixed:max(DATEPART('week',[Order Date]))}
        then [Sales]
        END
    ELSEIF [select a date unit] = 2 then 
        if [week or month] = {fixed:max(DATEPART('month',[Order Date]))}
        then [Sales]
        END
    END
  4. Drag week or month to Columns, Sales to Rows, Category to Color, most recent label to Label
  5. Exclude the newest point of Furniture.
  6. Confirm Label for Furniture is no longer shown in the view.
Did this article resolve the issue?