Billy
Billy

Reputation: 23

Using the ifnull statement with an if statement

I am trying to find the logic/calculated field for this question:

Turnover at or below the overall average turnover time for the service.
When turnover is null, assume that it was the average turnover time for the hospital and procedure.

This is what I came up but I am new to tableau so can somebody correct my syntax so it doesn't read an error:

IF ISNULL([Turnover]) THEN [Averageturn OVER]
ELSEIF [Turnover]> [AverageTurn over ] THEN "Over"
ELSEIF[Turnover]< [AverageTurn over ] THEN "under"
ELSE "average"
END

the error its reads is that expected a float type not a string. But how can I make it a string if I am expecting the null values to be replaced with the average turnover? Any ideas or help will be awesome

Upvotes: 1

Views: 188

Answers (1)

Siva
Siva

Reputation: 9101

Convert average turnover to string, replace average turnover to string, so your condition would be:

IF ISNULL([Turnover]) THEN STR([Averageturn OVER])
ELSEIF [Turnover]> [AverageTurn over ] THEN "Over"
ELSEIF[Turnover]< [AverageTurn over ] THEN "under"
ELSE "average"
END

Upvotes: 1

Related Questions