4 Replies Latest reply on Jun 29, 2015 11:59 AM by David Pires

# Calculate within a dimension pt2

Hi

Hope you can help me.

I've attached a workbook and what I'd like to be able to do is to calculate between those two years, but those two years can change, i.e. they could be 2009 and 2020.

In excel I'd do something like

x = 2014/2013*100.

One thing i seem to be struggling in to know the syntax to calculate within specific dimensions.

David

• ###### 1. Re: Calculate within a dimension pt2

Hi David,

If you want your years to be able to change, what you can do is set up a parameter to represent an editable number.

Here I represent 2013 and 2014 with parameters called [Year 1] and [Year 2]

Notice how the year range is 2000 to 2020: that mean you can select any integer between these numbers as your year.

Then do the same for year 2...

And then create your calculated field: [Year 1]/[Year 2]*100

I've attached the workbook. Let me know if that helps

1 of 1 people found this helpful
• ###### 2. Re: Calculate within a dimension pt2

This is good Ailsa Zheng but,let's say for instance that you don't want to type the year. You just want to pick from a selection, in this example they are years but they could be product names or places. How would you deal with that?

Thanks

David

• ###### 3. Re: Calculate within a dimension pt2

Does anyone know how to apply Alisa's suggestion but for elements within the dimension?

• ###### 4. Re: Calculate within a dimension pt2

Finally….

So I’d spent the last few weeks trying to come up with a solution for our year on year month on month calculations and how to display them. I got some help from the Tableau team, but we weren’t quite there yet. I thought I’d share this solution in case it helps someone.

Initially I thought about using parameters to create a calculation between items in a dimension. That’s not a problem when dealing with categories as these are likely not to change that often. However when using dates it becomes tricky, often we only want to see one number and allow the user to select the range.

Inspired by the link below from Peter Gilks

Paint By Numbers: Tableau Tip - The End of Time.... series based calculations

I was able to create what I need and I’ve published a workbook in case someone wants to have a look.

https://public.tableau.com/views/DynamicKPIs/Dashboard1?:embed=y&:showTabs=y&:useGuest=true&:display_count=yes

Thanks Peter Gilks, you've saved me days of work.

David