1 Reply Latest reply on Feb 12, 2015 3:45 PM by Patrick Van Der Hyde

# SUMIF type calculation based on groups of years

Hi there,

So I have a timeseries set of data and I need to run calculations to get aggregated % values based on groups of years.

For example, 2011-2013 would be group 1, 2014-2016 would be group 2, 2017-2022 would be group 3 (note they are not all the same size). I want to sum X over 2011-2013 and divide by Y over 2011-2013, in order to get % Z that applies to the aggregate group 1 period (2011-2013).

It's an easy SUMIF in Excel. How can I do this in Tableau?

Thanks!

Aaron

• ###### 1. Re: SUMIF type calculation based on groups of years

Hello Aaron Burdick,

One thought for a solution would be to use calculated fields to bucket the data:

This would be a row level if/then statement to consider to get group A measure value:

if [DateField}>=1/1/2011 and [DateField]<=12/31/2013 then [measure] End

and so one through each grouping.  The issue comes into how these measures are used in a view.  If the values are just totals with the view not partitioning the view in any way this will be quite easy. See the attached example workbook with 2011, 2012 and 2013 sales and a percentage of 2011 sales divided by 2012.

I hope this helps.

Patrick