# Calculate last year data without aggregating or using windows max

Hi,

I have attached a tableau workbook where I have tried to calculate the data from last year from same period as this year's data.

I have three columns YearWeek, First day of week and EUR.

I would like to sum up the 9.3.2015 data as it is more than first week of 2015 and less than last week of 2016.

How could I calculate the last years data without need of aggregating EUR or using windows max? I have managed to sum up the amount but it is working only when I put YearWeek in the view.

BR

• ###### 1. Re: Calculate last year data without aggregating or using windows max

Andy Kriebel just posted a blog on this subject, using LoD calculations. I think his tutorial should get you going: Tableau Tip Tuesday: Using LOD Calcs for Year over Year Comparisons

- Derrick

1 of 1 people found this helpful
• ###### 2. Re: Calculate last year data without aggregating or using windows max

Hi Derrick,

Thanks for the tips. I came up with the solution that seems to be working the way I wanted.

For there who have similar problem, this might save a lot of hours.

IF LEFT(STR([YearWeek]),4) =STR(YEAR(TODAY())-1) and {MAX([YearWeek])}-[YearWeek]>=100

THEN ([EUR])

ELSE null

END

For someone who might be new to LOD {MAX([YearWeek])} is the solution to this problem. You basically ask Tableau to provide MAX year week. This is kind of handy as you won't need to use table calculation and also you can use aggregates later.

BR