on 05-17-2012 9:05 PM
Hi All
I am trying to create a calculated attribute age group for an age attribute for example if the age is between 30 -35 the age group column shoul have 30-35 as the age group corresponding to the record.I tried to create using IF condition but I am facing invalid expression error I am trying to put the condition as below
if("AGE" >=50 AND <=55,'50-55') but it is not working .Request for help in creating the calculated attribute.
Regards
Santosh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Santosh,
Please use the following expression:
if("AGE" >= '35' AND "AGE" <= '40', 'yes', 'no')
you can replace 'yes' and 'no' with your requirement.
Here, Datatype of the "AGE" is NVARCHAR that why i used '35', if in case Datatype is "AGE" in INTEGER the you can use 35 instead of '35'.
Please check this.
Hope it is useful.
Regards,
neha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Neha
I don't know why it was saying Inavlid expression but when I activated the attribute view it did not throw any error , it gave the result as desired.now the below is working fine.I will try to replicate the same using CASE statement
if("AGE" >=20 AND "AGE" <=25,'20-25',
if("AGE" >=30 AND "AGE" <=35,'30-35',
if("AGE" >=35 AND "AGE" <=40,'35-40',
if("AGE" >=40 AND "AGE" <=45,'40-45',
if("AGE" >=45 AND "AGE" <=50,'45-50',
if("AGE" >=50 AND "AGE" <=55,'50-55',
if("AGE" >=55 AND "AGE" <=60,'55-60','60-65')
)
)
)
)
)
)
Thanks
Santosh
Hi Santosh,
Try this if("AGE" >=50 AND "AGE" <=55,'50-55') instead.
Thanks,
Anooj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the reply, but the above syntax is also not workng ,when I saw the modelling guide the syntax is as below.I have multiple if conditions to use .I tried to replicate that but it did not work.
if("NETWR"<=500000,'A',
if("NETWR"<=1000000,'B','C')
)
Let us see what others say
Thanks
Santosh
Hi Anuj
I don't know whya it was saying Inavlid expression but when I validate and activated it , it gave th result as desired.
now the below is working fine.Thanks for your help
if("AGE" >=20 AND "AGE" <=25,'20-25',
if("AGE" >=30 AND "AGE" <=35,'30-35',
if("AGE" >=35 AND "AGE" <=40,'35-40',
if("AGE" >=40 AND "AGE" <=45,'40-45',
if("AGE" >=45 AND "AGE" <=50,'45-50',
if("AGE" >=50 AND "AGE" <=55,'50-55',
if("AGE" >=55 AND "AGE" <=60,'55-60','60-65')
)
)
)
)
)
)
Thanks
Santosh
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.