tableau创建计算字段,进行年龄段分类

分析-创建计算字段,可对字段进行计算

if (DATEDIFF('year',[birthday],NOW()) <=18)

   then '未成年'

   ELSEIF ( 19<=DATEDIFF('year',[birthday],NOW())and  DATEDIFF('year',[birthday],NOW())<=23)

   then '大学生'

   ELSEIF (24<=DATEDIFF('year',[birthday],NOW()) and  DATEDIFF('year',[birthday],NOW())<=28)

   then '初入职场'

   ELSEIF  (29<=DATEDIFF('year',[birthday],NOW())and  DATEDIFF('year',[birthday],NOW())<=35)

   then '职场精英'

   ELSEIF  (36<=DATEDIFF('year',[birthday],NOW())and  DATEDIFF('year',[birthday],NOW())<=45)

   then '中年人士'

ELSE  '养生人士'

END

你可能感兴趣的:(tableau创建计算字段,进行年龄段分类)