Arsee
Arsee

Reputation: 671

Tableau - How to display last # of days on a line chart

I have a tableau line chart report where the X axis is the Call Date, I'm trying to display dynamically the last 14 days, but unable to do it in tableau. In T-SQL I can easily do WHERE CallDate between CONVERT(VARCHAR,GETDATE()-14,101) and CONVERT(VARCHAR,GETDATE()-1,101)

enter image description here

For example, the line chart below, I want to display Sept 1 to 14 then when Sept 15 comes Sept 1 will drop from the line chart view so on and so forth. I tried to use the Top N, but it is not displaying correctly.

Upvotes: 1

Views: 574

Answers (2)

Larry Li
Larry Li

Reputation: 133

EDITED:

You can create a calculated field to select the last 14 days, and then apply it as the filter in your chart.

Calculated Field:

[Date] > DATEADD('day', -14, TODAY()) AND [Date]<= TODAY()

If you want the days to be dynamic and can be selected by user, you can create a parameter and use it in the calculated field.

[Date] > DATEADD('day', -[Days], TODAY()) AND [Date]<= TODAY()

The [Days] here is the name of parameter.

enter image description here

Upvotes: 1

sqlearner
sqlearner

Reputation: 65

Drag your "Call Date" to Filters card and select "Relative Dates" then select "Last 14 days" and hit OK. This will make the filter dynamic.

Upvotes: 2

Related Questions