7 Replies Latest reply on May 19, 2017 2:16 PM by Gurpreet Singh Goraya

# Create custom icons with conditions

Hello All,

I want to create custom icons based on the following conditions and based on 15 minutes time interval:

1. If Sum of Amb>3 and  <= 6 then

2. If Sum of Amb <=3 then

3. If 1 wheelchair and <= 3 Amb then

4. If Sum of Amb >6 and <=12 then

5. If Sum of Wheelchair >1 then

If the conditions match, I want them to display as an icon instead of numbers as you will see in the worksheet. Please let me know if you have any questions. I would appreciate the help. Thanks

Gurpreet

• ###### 1. Re: Create custom icons with conditions

There are quite a few articles on how to use custom shapes, so that's what you're going to do to get those shapes on your sheet.  I won't describe that.

What you need to do is create a calc that will assign a discrete value (perhaps "A", "B", "C", etc.) to your various conditions.  And then you will put that calc on the sheet as a SHAPE mark.  See sheet 2 of the attached for an example.  I just used SUM(NUMSPACESPU) and made it discrete.  Tableau shows that you have 12 values for that pill, and has assigned 12 of its stock shapes to the individual values.  You will put your calc on SHAPES instead, and assign your various custom shapes to the appropriate values.

Now I'm not sure if your will want to mix shapes AND values.  (Maybe some values or some conditions won't be assigned to a shape.

In Sheet 3 I made two calcs that split SUM(NUMSPACESPU) into two chunks -- those with values from 1-through-6 get a shape.  Those with value 7 or more get a number.

Now, what really happens here is that for the shapes calc, values 7 and higher get set to NULL, and that actually gets assigned a shape.  If you scroll down to EVSTRNAME 128, you will see the value 7 superimposed on the circle.

So when you set up your custom shapes, create one that actually looks invisible.  Then just the number will appear.  Alternatively you can do what I did on Sheet4 and also assign colors.  I assigned the same color to the various shapes, except for the NULL value, where I assigned white.  (Which makes it look invisible.)

Anyway, these are some ideas to get you started.

• ###### 2. Re: Create custom icons with conditions

Thank you Joe for the reply. I really appreciated that. I am in doubt how to create a calculated field if there are a wheelchair and ambulatory passenger. See screenshot below:

Thank you again.

Gurpreet

• ###### 3. Re: Create custom icons with conditions

If SUM([Amb]) >3 and  SUM([Amb]) <= 6 then "A"

ELSEIF SUM([Wheelchair]) = 1 and SUM([Amb]) <= 3 then "B"

ELSEIf SUM([Amb]) <=3 then "C"

ELSEIF SUM([Amb]) >6 and SUM([Amb]) <=12 then   "D"

ELSEIF SUM([Wheelchair]) >1 then  "E"

else "F"

END

Something you need to be careful about.  When Tableau is evaluating a multi-condition like this, as soon as a TRUE condition is hit, Tableau stops evaluating.  So, for instance, I swapped the order of condition 2 and 3 from your original list.  That's because originally you had <=3 for the second condition, and you want a special condition to be detected for <=3 AND wheelchair.  But if we had your original condition #2 before #3, it would never get to #3 because all <=3 would be caught by #2 whether or not a wheelchair was involved.

And therefore you have to look closely at  SUM([Wheelchair]) >1.  Suppose you have  SUM([Wheelchair]) >1  AND SUM(Amb) = 4.  In that case the first condition would evaluate as true, and you would never drop to the "E" condition.  Maybe that's what is supposed to happen by your business logic.  But if you want that "E" condition to get hit regardless of the sum of [Amb], then you would want that one at the top of the logic.

I would have made a calc like this in the example I uploaded, but I didn't find those fields to play with.

The syntax I gave in this reply I just typed off the top of my head.  You may still get some syntax error, but I would think you would be able to correct that on your own.

• ###### 4. Re: Create custom icons with conditions

Thank you again Joe for the help.

Gurpreet

• ###### 5. Re: Create custom icons with conditions

Hi Joe,

Sorry to bother you. To make the calculation worked, I applied the following:

If SUM([WC]) >1 then  "C"

Elseif SUM([Amb]) >3 and  SUM([Amb]) <= 6 then "M"

ELSEIF SUM([WC]) = 1 and SUM([Amb]) <= 3 then "XT"

ELSEIf SUM([Amb]) <=3 then "S"

ELSEIF SUM([Amb]) >6 and SUM([Amb]) <=12 then   "P"

else "F"

END

Now I am experiencing another issue, For an example; the Evstrname 106 have 1 amb and 1 wc and it meets the condition XT (Third statement in the formula). But it is showing me "S" and "XT". Is it possible it should show only XT in that case because XT can absorb 1 wheelchair and up to three ambulatories? Please let me know if you have any questions. Thanks
• ###### 6. Re: Create custom icons with conditions

Tableau is doing that calc at the level of dimensionality you have on the sheet.

See the attached Sheet3.  Tableau looks at SUM(WC), for example, taking into account ALL the dimensions on the sheet.  Start pulling off [Time Group] and [WC and Amb] one by one from the sheet, and you'll see the mix of error codes change based on the SUM(whatever) at the level of the remaining dimensions.

If you want Tableau to sum up those measures without taking into account those dimensions, either take them off the sheet, or use LODs or table calcs to sum them up differently.

• ###### 7. Re: Create custom icons with conditions

Thank you Joe for the reply. I was able to figure out the resolution. I could not get about errors you are talking about. As advised I removed AMB and WC from the worksheet results seems to me comparable. Thanks

Gurpreet