Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
In my dataset I have a "Age" field and I want o create a new calculated field based on the existing "Age" field named as "Age Category" in such a way that :
0 - 12 : Kid
13 - 17 : Teen
18 - 64 : Adult
Above 65 : Senior
I have used the following expression to create the field but It is not working, It shows Incomplete visualization in the
preview section. How to resolve this?
If(Age >= 0 & Age < 13,'Kid',
IF(Age >= 13 & Age<18,'Teen',
IF(Age >=18 & Age< 65,'Adults',
if(Age >= 65,'Senior'))))
Are you using the Data Load Manager? It unfortunately does not allow the use of AND statements, so you'll have to just follow the nested if() statements. Which may actually be preferable in the first place since it's shorter (but somewhat harder for a human to read, I guess):
If(Age < 13, 'Kid',
if(Age < 18, 'Teen',
If(Age < 65, 'Adult', 'Senior')))
Use "and" rather than "&".
@Or wrote:
Use "and" rather than "&".
Even I tried with that, if I use "and" it will shows 'no preview enter valid expressions'.
Try this
If(Age >= 0 and Age < 13,'Kid',
IF(Age >= 13 and Age<18,'Teen',
IF(Age >=18 and Age< 65,'Adults',
if(Age >= 65,'Senior')))) as FieldName
if this is not working, please share the sample data.
Are you using the Data Load Manager? It unfortunately does not allow the use of AND statements, so you'll have to just follow the nested if() statements. Which may actually be preferable in the first place since it's shorter (but somewhat harder for a human to read, I guess):
If(Age < 13, 'Kid',
if(Age < 18, 'Teen',
If(Age < 65, 'Adult', 'Senior')))
Result:
LOAD *,
If(Age >= 0 and Age <= 12, 'Kid',
If(Age >= 13 and Age <= 17, 'Teen',
If(Age >= 18 and Age <= 64, 'Adult',
If(Age >= 65, 'Senior')
)
)
) as [Age Category]
RESIDENT [YourTableName];
*** When applicable please mark the correct/appropriate replies as "solution". Please LIKE threads if the provided solution is helpful to. ***