2 Replies Latest reply on Apr 7, 2016 6:53 AM by Dan Zehner

Can't compare Boolean and Float values

I'm working on a calculated field and I'm a bit stumped by this error "Can't compare Boolean and Float values." Here's my calculation (so far I only have the Infant Mortality Cause type in there, but there will be two more sections just like this for Constant Failure and Degradation types):

If [Cause Type]= "Infant Mortality"

And [% Fail]<=.0044

Then 1

Elseif [Cause Type]= "Infant Mortality"

And .0044<=[% Fail]<=.025

Then 2

Elseif [Cause Type]= "Infant Mortality"

And .025<=[% Fail]<=.09

Then 3

Elseif [Cause Type]= "Infant Mortality"

And .09<=[% Fail]<=.22

Then 4

Elseif [Cause Type]= "Infant Mortality"

And .22<=[% Fail]<=.49

Then 5

Elseif [Cause Type]= "Infant Mortality"

And .49<=[% Fail]<=.96

Then 6

Elseif [Cause Type]= "Infant Mortality"

And .96<=[% Fail]<=1.7

Then 7

Elseif [Cause Type]= "Infant Mortality"

And 1.7<=[% Fail]<=2.9

Then 8

Elseif [Cause Type]= "Infant Mortality"

And 2.9<=[% Fail]<=4.5

Then 9

Elseif [Cause Type]= "Infant Mortality"

And 4.5<=[% Fail]

Then 10

END

Cause Type is a String field, and %Fail is Number (Decimal), so I'm wondering why Tableau thinks I'm using a Boolean data type for these fields... Basically what I'm trying to do is create two levels of bins for this data, the first level would categorize the data by Cause Type (Infant Mortality, Constant Failure, Degradation), then by the % Fail ranges specified within that type (they're different for each one). If someone has a better idea for how to accomplish this than the way I'm going about it as well I'm all ears! Thanks in advance!

• 1. Re: Can't compare Boolean and Float values

Looks like I figured it out! Here's the new calculation:

If [Cause Type]= "Infant Mortality"

And [% Fail]<=.0044

Then 1

Elseif [Cause Type]= "Infant Mortality"

And .0044<=[% Fail]

Then 2

Elseif [Cause Type]= "Infant Mortality"

And .025<=[% Fail]

Then 3

Elseif [Cause Type]= "Infant Mortality"

And .09<=[% Fail]

Then 4

Elseif [Cause Type]= "Infant Mortality"

And .22<=[% Fail]

Then 5

Elseif [Cause Type]= "Infant Mortality"

And .49<=[% Fail]

Then 6

Elseif [Cause Type]= "Infant Mortality"

And .96<=[% Fail]

Then 7

Elseif [Cause Type]= "Infant Mortality"

And 1.7<=[% Fail]

Then 8

Elseif [Cause Type]= "Infant Mortality"

And 2.9<=[% Fail]

Then 9

Elseif [Cause Type]= "Infant Mortality"

And 4.5<=[% Fail]

Then 10

END

I guess Tableau didn't like having the XX<=[% Fail] <= YY syntax for some reason.

• 2. Re: Can't compare Boolean and Float values

Looks like I spoke too soon... I'm getting some Null values where it should be assigning a 1 for some reason. They're all Constant Failure Rate with a very low % Fail (0.00005), so they should be assigned a 1 by this part of the calculation:

ELSEIF  [Cause Type]= "Constant Failure Rate"

And [% Fail]<=.000033

Then 1

Any ideas?