0
votes

I've exhausted my understanding of Tableau. I'm trying to color every icon below the risk average the color red, and above the color green. Here is an attempt at an articulation in Java of my intention (this code may not be correct, but I want the intention translated into Tableau).

This is my Tableau code that doesn't work:

IF [Commercial Services] <= [Risk Average] *The variable I want to create* 
THEN "Red"

ELSEIF [Commercial Services] > [Risk Average]
THEN "Green"

END

Here's the Java code I think is closer to what I need converted:

final int NUM_ROWS = 39;
int count = 0;

while(count < NUM_ROWS) {
if(count.commercial_services < count.risk_average) {
        shape.color = "Red";
    } elseif(count.commercial_services > count.risk_average) {
        shape.color = "Green";
    } else {
        shape.color = "Blue";
    }
    count++;
}

Please help me create a variable that I could use to color each risk in reference to the risk average.

I have attached a spreadsheet and an image for reference.

https://i.stack.imgur.com/GaWQm.png

Thanks in advance.

1
That is quality image editing :)Seblor

1 Answers

1
votes

That is not the way Tableau works. For such purposes, you should first create a flag-like calculated field to form values according to your conditions. And then use that field as a shape or color identifier dragging it to the Marks card.

So for your case you may create a field like below (which is almost the same you did), which means it will have the value of "Red" for CS<=RA condition and "Green" for the other condition. Only that Tableau does not know what to do with these string variables at the moment. You may assign -1 or 1 instead of these strings, it does make no change.

IF [Commercial Services] <= [Risk Average]
THEN "Red"

ELSE "Green"

END

And now you have new column in your data which have "Red" or "Green" values at each row. You may now drag this field to Marks card and select is as Color or as normal pill and select its type as Shape then use standard arrows or make your custom shapes according to your needs. At this phase, you will be selecting with which colours or shapes should your "Red" & "Green" values be represented by.

I or someone else might be in more help if you share your tableau workbook with what you have done so far.