KNOWLEDGE BASE

Dual Line Graph Comparing With Same Month Same Weekday Previous Year


Published: 08 Dec 2022
Last Modified Date: 08 Dec 2022

Question

How to make a Dual Line Graph Comparing With Same Month Same Weekday Previous Year

Environment

  • Tableau Desktop

Answer

1. Create a parameter to choose a month you want to display.
User-added image

2. Create the following calculations.

[This Year]

SUM(IF 
DATETRUNC('month',[Order Date])=[Choose a month]
THEN [Sales] END)

[Previous Year]

LOOKUP(SUM(IF 
DATEADD('day',-364,[Choose a month])<=[Order Date]
AND
DATEADD('day',-364,DATEADD('month',1,[Choose a month])-1)>=[Order Date]
THEN [Sales] END),
DATEADD('year',1,
DATEADD('day',-364,[Choose a month])
)-[Choose a month]
)

3. Drag [Measure Names] to [Filters] and choose [This Year] and [Previous Yeas]

4. Drag [DAY(Order Date)] to [Columns], [Measure Values] to [Rows], [Measure Names] to [Color]
Did this article resolve the issue?