4 Replies Latest reply on Sep 28, 2016 11:31 AM by Steffen Nielsen

# Calculated constant

I have struggled with an issue for quite some time now.

I am trying to create what you might call a calculated constant, or something similar. I am trying to create a constant that I can use across multiple rows, that are independant of the data on that particular row.

I can create a Parameter with just a constant in it - however I want to control the constant using som calculation.

Anyone have an idea on how to do that?

Lets say I have a dataset with the following columns: Year, Color, Sector, Income and cost.

Where "Color" can contain: "Green", "Blue", "Red" and Sector can contain e.g. "Retail", "Trade", "Housing", "Agriculture".

Say I want to display the income in all the sectors (down) and year (across) (not split by color). I then want to add the the "green" income/cost-ratio in year 2016 to all rows. How can I do that?

I can add the color dimension and note down the ratio for the green (e.g. 150) and just create a parameter with the constant value of 150 and add it to my table - but I want it to be dynamic to a certain degree.

I tried to do a calculated field with some "Fixed" dimensions - but that does not do the job.

Is this possible, or will I have to add a new datasource where I have grouped the data as I want?

• ###### 1. Re: Calculated constant

You don't need a new data source.  LODs or Table Calcs will take care of this.

Post a sample packaged workbook.  Specify the version of Tableau you are on.  A concrete example will give you a concrete example solution!

• ###### 2. Re: Calculated constant

See attached example of what I am trying to do.

I am on Tableau 10.0

• ###### 3. Re: Calculated constant

In the attached I created the numbers using table calcs in the "Include Color" sheet.  I just threw the values onto the text shelf...  They appear for all rows (if there is data there).

For the record, I added an extra function into the process.  You can pick which color you want to do the calcs for.

In the "Cost/Income..." sheet I used LODs to grab the green data, and a table calc to compute the final result.  You can discard [Calc1] and [Calc2] from the viz.  I just left them on there for demonstration purposes.

• ###### 4. Re: Calculated constant

Thank you so much - this works like a charm :-)