6 Replies Latest reply on Dec 22, 2015 6:13 AM by Tableau kumar

# Conditional Formatting-Color codes

HI

Can anyone help me in solving the formula for the below requirement.

I want my color code for the circles to change based on the X & Y axis selection.in Y axis I have option to select either TCU or Competition.

I am able to achieve the desired below view when my Y axis is selected as TCU based on the below formula.

IF ATTR([Industry])>0 and ATTR([TCU])>0 THEN 'MoreGreen'

ELSEIF ATTR([Industry])<0 and ATTR([TCU])<0 THEN 'DarkRed'

ELSEIF  ATTR([TCU])<0 then 'red'

ELSEIF ATTR([TCU])>0 THEN 'Green'

END

• ###### 1. Re: Conditional Formatting-Color codes

I assume you are switching measures on the Y-axis using a parameter and calculated field?

If so simply reference the calculated field in your IF statement rather than TCU? Are TCU and competition on the same scale and is 0 the switch in both cases?

Or is the question how to switch the Y-Axis in the first place?

• ###### 2. Re: Conditional Formatting-Color codes

Hi,

Post the sample twbx file do that we can try

• ###### 3. Re: Conditional Formatting-Color codes

IF ATTR([Industry])>0 and ATTR([TCU]/[Competition])>0 THEN 'MoreGreen'

ELSEIF  ATTR([Industry])<0 and ATTR([TCU]/[Competition])<0 THEN 'DarkRed'

ELSEIF  ATTR([TCU]/[Competition])<0 then 'red'

ELSEIF ATTR([TCU]/[Competition])>0 THEN 'Green'

END

Yes I have used Parameter and Calculated field formula as above.But, I am only getting 2 colors Green and Dark Green.

Please let me know if the above formula needs any changes.

• ###### 4. Re: Conditional Formatting-Color codes

Tableau Viz: Writing Conditional calculations in Tableau

1) You have to create a calculated field using Parameter to show the specific measure on the view.

Name: Selected KPI

Syntax: if [Parameter] = "TCU" then [TCU]

else [Competition]

end

2) Use the the above calculated field & make a calculation.

if [Industry] >0 and [Selected KPI] >0 then "More Green"

elseif  [Industry] <0 and [Selected KPI] >0 then "DarkRed"

elseif   [Selected KPI] >0 then "Green"

elseif   [Selected KPI] <0 then "Red"

end

Best Regards

Kumar

• ###### 5. Re: Conditional Formatting-Color codes

I got the desired result in my approach

• ###### 6. Re: Conditional Formatting-Color codes

Once you find the Solution from any one' post, then mark it as "Answered", else you get the answer yourself then share the solution in the forum for future references.