Hello All,
This blog is related to most common question, what is the difference between IF and IIF? Read the below comments and you will have the exact information about this.
1) IF can't return Boolean whereas IIF can return Boolean also.
2) IF is like a statement in syntax (IF test THEN '' ELSE '' END) where as IIF is like a function
3) IF takes 3 values whereas IIF takes 4 parameters.
4) ELSEIF can be use with IF but there is no way to use ELSEIF with IIF.
This blog is related to most common question, what is the difference between IF and IIF? Read the below comments and you will have the exact information about this.
1) IF can't return Boolean whereas IIF can return Boolean also.
IF 1=1 THEN TRUE ELSE FALSE END // This will give you error, cannot use Boolean type with IF expression.
IIF(1=1,TRUE,FALSE) // This will execute perfect.
2) IF is like a statement in syntax (IF test THEN '' ELSE '' END) where as IIF is like a function
IIF(test,then,else,[unkown])
3) IF takes 3 values whereas IIF takes 4 parameters.
4) ELSEIF can be use with IF but there is no way to use ELSEIF with IIF.
Tableau Desktop References:
IF <expr> THEN <then> [ELSEIF <expr2> THEN <then2>...]
[ELSE <else>] END
Tests a series of expressions returning the <then> value for the first true <expr>.
Example: IF [Profit]>0 THEN 'Profitable' ELSEIF [Profit] = 0 THEN 'Breakeven' ELSE 'Loss' END
IIF(test, then, else, [unknown])
Checks whether a condition is met and returns one value if TRUE, another value if FALSE, and an optional third value or NULL if unknown.
Example: IIF([Profit]>0,'Profit','Loss').
If you have any question, please comment below.
No comments:
Post a Comment