9 Replies Latest reply on Jul 17, 2014 8:55 AM by Aaron Clancy

# Show values for two different time periods for one measure

Is this possible?

I have a rolling time series in which I'm trying to display yesterday's date with a look-back of one year's time sliced by YearWeek, but I need to show the aggregated values stacked in the same bar for Current Year versus Previous Year by YearWeek, so that growth is visually displayed.

The data filter for my viz is:

IF Date>=(DATEADD("year",-2,TODAY()-1))AND Date<=TODAY()-1 THEN 1 ELSE 0 END

Where Filter = 1

However, my viz shows the entire span of time with each bar as its own YearWeek.  I need to take one measure (SUM of dollars) and break it out as different visualizations.

• ###### 1. Re: Show values for two different time periods for one measure

I'm having a hard time understanding what the filter is for.

Here's a screenshot of year over year week comparisons.  Let me know if this heading down the right path or if I'm way off point with the requirements.

(My data doesn't have current dates so applying the moving 1 year from current doesn't make sense but if you need help with that logic I can add it.)

• ###### 2. Re: Show values for two different time periods for one measure

That's a close viz and ultimately what I'm aiming for, but the time series weeks on the bottom (x-axis), while spanning 52-weeks, is a rolling period, where the most recent week's data is to the right and the least recent week's data (both aggregated) are to the left.  So the time series is essentially constantly evolving.

So for example charting along the x-axis, your time series prior to turning over would be something like:

2013-28, 2013-29, 2013-30.....2014-25, 2014-26, 2014-27, with that entire time period covering 52 weeks

When the next week changes over (Week ends Sundays, starts Mondays), it would look something like this:

2013-29, 2013-30, 2013-31.....2014-26, 2014-27, 2014-28, with that entire time period still covering 52 weeks

In other words, at the turn of the new week, you drop the oldest week's worth of data covering the 52 week time period, and you add the most recent week's worth of data, starting right, ending left across the continuum (x-axis).

• ###### 3. Re: Show values for two different time periods for one measure

Would a filter like this work:

datediff('day',[Order Date],today())<730

If you're concerned with leap year then some variation of the filter you proposed should work right?

• ###### 4. Re: Show values for two different time periods for one measure

No.  I already have a filter that accounts for the data that I need, which I described in my original post.

The issue is when I use that filter I need to hide everything but the most recent 52 weeks grouping on my x-axis, but still use the data for year/year comparison by YearWeek.

• ###### 5. Re: Show values for two different time periods for one measure

Let me know if this is it:

This does a lookup of 52 weeks ago with a last() filter so that it shows only the last 52 weeks of data.  Table calc filters only hide the data so the previous year isn't getting "filtered"

• ###### 6. Re: Show values for two different time periods for one measure

That definitely looks like it could be it!  I will try it out based on your viz here, but any other tips you have would be great.

How did you approach your "Last Year's" calc?

• ###### 7. Re: Show values for two different time periods for one measure

I made some minor tweaks to get the lookups right:

• ###### 8. Re: Show values for two different time periods for one measure

Unfortunately my Tableau is not setup to view your attached workbooks.  Just curious how you came up with the previous year calculation based on a measure, given that I need to keep the rolling time axis?

Thanks!

• ###### 9. Re: Show values for two different time periods for one measure

If you do a continuous Year week date field and then create a measure calc for last years week value:

lookup(sum([Sales]),-52)         //compute using table across

You can stack the current weeks with last year's week by using measure names and measure values.

And then set the range of the "last()" filter to 0-51