Search code examples
tableau-api

how to show last quarter data in tableau


I have a dashboard where I have data for each month for last 1 year.

Now I need to show data for last quarter (July-Sep)

Could anyone please help me what is the formula we need to write to get last quarter.

enter image description here

enter image description here


Solution

  • EDIT (based on question update):

    sum(
        if (    QUARTER([Date]) = QUARTER(DATEADD('quarter',-1,TODAY()))
            and YEAR([Date]) = YEAR(DATEADD('quarter',-1,TODAY()))
           ) then [Value]
        end
    )
    

    If you're using Tableau version older than 2019.3, you have to replace QUARTER with:

    datepart('Quarter', [Date])