2 Replies Latest reply on Aug 9, 2013 4:26 PM by Kiran v

    I have a date related 'ELSEIF' question, if I want to create aliases for dates in tableau

    Kiran v

      How to create date related elseif calculated field in tableau if I want to put a filter on dates. For example I want to segment my dates in my back end data like this :-

       

      case

          when STAY_DT between '01-JAN-2013' and '29-JAN-2012' then 'P1'

          when STAY_DT between '30-JAN-2012' and '26-FEB-2012' then 'P2'

          when STAY_DT between '27-FEB-2012' and '01-APR-2012' then 'P3'

          when STAY_DT between '02-APR-2012' and '29-APR-2012' then 'P4'

          when STAY_DT between '30-APR-2012' and '27-MAY-2012' then 'P5'

          when STAY_DT between '28-MAY-2012' and '01-JUL-2012' then 'P6'

          when STAY_DT between '02-JUL-2012' and '29-JUL-2012' then 'P7'

          when STAY_DT between '30-JUL-2012' and '26-AUG-2012' then 'P8'

          when STAY_DT between '27-AUG-2012' and '30-SEP-2012' then 'P9'

          when STAY_DT between '01-OCT-2012' and '28-OCT-2012' then 'P10'

          when STAY_DT between '29-OCT-2012' and '25-NOV-2012' then 'P11'

          when STAY_DT between '26-NOV-2012' and '31-DEC-2012' then 'P12'

          when STAY_DT between '01-JAN-2013' and '27-JAN-2013' then 'P1'

          when STAY_DT between '28-JAN-2013' and '24-FEB-2013' then 'P2'

          when STAY_DT between '25-FEB-2013' and '31-MAR-2013' then 'P3'

          when STAY_DT between '01-APR-2013' and '28-APR-2013' then 'P4'

          when STAY_DT between '29-APR-2013' and '26-MAY-2013' then 'P5'

          when STAY_DT between '27-MAY-2013' and '30-JUN-2013' then 'P6'

          when STAY_DT between '01-JUL-2013' and '28-JUL-2013' then 'P7'

          when STAY_DT between '29-JUL-2013' and '25-AUG-2013' then 'P8'

          when STAY_DT between '26-AUG-2013' and '29-SEP-2013' then 'P9'

          when STAY_DT between '30-SEP-2013' and '27-OCT-2013' then 'P10'

          when STAY_DT between '28-OCT-2013' and '24-NOV-2013' then 'P11'

          when STAY_DT between '25-NOV-2013' and '31-DEC-2013' then 'P12'

          else 'KC'

          end as PERIOD,

       

      Any assistance is appreciated.