If I am understanding correctly, you are seeking to set the start and end points of colors
differently for each metric.
Tableau can automatically set it to the max and min based on that metric, but if you seek to
hard code those points, you could try a calculated field like:
IF [Select Metric]="Sales" AND [Selected Metric]< 10000 THEN 10000
ELSEIF [Select Metric]="Sales" AND [Selected Metric]> 300000 THEN 300000
ELSEIF [Select Metric]="Profit" AND [Selected Metric]< -20 THEN -20
ELSEIF [Select Metric]="Profit" AND [Selected Metric]> 150 THEN 150
ELSEIF [Select Metric]="Discount" AND [Selected Metric]< .1 THEN .1
ELSEIF [Select Metric]="Discount" AND [Selected Metric]> .6 THEN .6
ELSE [Selected Metric]
This should fix the endpoints of the color scale according to the metric.
Please see the workbook attached in the Forum Thread.
264693color.twbx 1.2 MB
Thanks for your answer,
But this code doesn't solve my problem. it maps the values of the selected metric to new values, but I don't want to change my values.
In the quantitative colour palette, if we do not set the end and start of the range, tableau will automatically set it to max and min of existing values( ie. in your dataset minimum profit is -36.2 and max is 204).
if I want to set a wider range for the color palette (ie. -100 to 500) I can set it with start and end in the following panel. But I want to set those from code without changing the values of metrics like profit?
1 of 1 people found this helpful
My apologies for misunderstanding.
I couldn't think of way to do that completely inside Tableau,
but there may be a way with some kind of data padding.
I'm likely wrong, but my feeling is that in order to code the start and end points,
the value will have to be somewhere in the data.
This may not at all be feasible for you, but one way to force external values
would be to put the highs and lows in a separate table and union that to your true data.
This may not be feasible for your datasource type or setup.
In the attempt attached in the Forum Thread, the data was in Excel in the form:
State | Metric1 | Metric2
Texas | 5 | -5
Florida | 15 | 0
And the range table to be unioned was:
State | Metric1 | Metric2
NullLow | -50 | -25
NullHigh | 200 | 50
These were unioned together.
The values for null states still showed up in color range and forced the endpoints,
but the null states themselves only appeared on the map in the lower right indicator of "2 unknown" ,
which can be dismissed.
This method allowed for setting of separate ranges for the different metrics.
This workaround solves my question, though I believe there should be a way without changing data!