14 Replies Latest reply on Nov 30, 2018 11:31 AM by Joe Oppelt

    creating an if statements in tableau

    Collins Pagarigan

      in excel this works connecting to BW adding this calculation to calculate week number is giving me. Cannot use if type in expression. Can someone help?

       

      if ([Calendar Day Level 01] >= #04-28-2018# and [Calendar Day Level 01] <= #05-04-2018#) then 'FY19 W1'

      elseif ([Calendar Day Level 01] >= #05-05-2018# and [Calendar Day Level 01] <= #05-11-2018#) then 'FY19 W2'

      elseif ([Calendar Day Level 01] >= #05-12-2018# and [Calendar Day Level 01] <= #05-18-2018#) then 'FY19 W3'

      elseif ([Calendar Day Level 01] >= #05-19-2018# and [Calendar Day Level 01] <= #05-25-2018#) then 'FY19 W4'

      elseif ([Calendar Day Level 01] >= #05-26-2018# and [Calendar Day Level 01] <= #06-01-2018#) then 'FY19 W5'

      elseif ([Calendar Day Level 01] >= #06-02-2018# and [Calendar Day Level 01] <= #06-08-2018#) then 'FY19 W6'

      elseif ([Calendar Day Level 01] >= #06-09-2018# and [Calendar Day Level 01] <= #06-15-2018#) then 'FY19 W7'

      elseif ([Calendar Day Level 01] >= #06-16-2018# and [Calendar Day Level 01] <= #06-22-2018#) then 'FY19 W8'

      elseif ([Calendar Day Level 01] >= #06-23-2018# and [Calendar Day Level 01] <= #06-29-2018#) then 'FY19 W9'

      elseif ([Calendar Day Level 01] >= #06-30-2018# and [Calendar Day Level 01] <= #07-06-2018#) then 'FY19 W10'

      elseif ([Calendar Day Level 01] >= #07-07-2018# and [Calendar Day Level 01] <= #07-13-2018#) then 'FY19 W11'

      elseif ([Calendar Day Level 01] >= #07-14-2018# and [Calendar Day Level 01] <= #07-20-2018#) then 'FY19 W12'

      elseif ([Calendar Day Level 01] >= #07-21-2018# and [Calendar Day Level 01] <= #07-27-2018#) then 'FY19 W13'

      elseif ([Calendar Day Level 01] >= #07-28-2018# and [Calendar Day Level 01] <= #08-03-2018#) then 'FY19 W14'

      elseif ([Calendar Day Level 01] >= #08-04-2018# and [Calendar Day Level 01] <= #08-10-2018#) then 'FY19 W15'

      elseif ([Calendar Day Level 01] >= #08-11-2018# and [Calendar Day Level 01] <= #08-17-2018#) then 'FY19 W16'

      elseif ([Calendar Day Level 01] >= #08-18-2018# and [Calendar Day Level 01] <= #08-24-2018#) then 'FY19 W17'

      elseif ([Calendar Day Level 01] >= #08-25-2018# and [Calendar Day Level 01] <= #08-31-2018#) then 'FY19 W18'

      elseif ([Calendar Day Level 01] >= #09-01-2018# and [Calendar Day Level 01] <= #09-07-2018#) then 'FY19 W19'

      elseif ([Calendar Day Level 01] >= #09-08-2018# and [Calendar Day Level 01] <= #09-14-2018#) then 'FY19 W20'

      elseif ([Calendar Day Level 01] >= #09-15-2018# and [Calendar Day Level 01] <= #09-21-2018#) then 'FY19 W21'

      elseif ([Calendar Day Level 01] >= #09-22-2018# and [Calendar Day Level 01] <= #09-28-2018#) then 'FY19 W22'

      elseif ([Calendar Day Level 01] >= #09-29-2018# and [Calendar Day Level 01] <= #10-05-2018#) then 'FY19 W23'

      elseif ([Calendar Day Level 01] >= #10-06-2018# and [Calendar Day Level 01] <= #10-12-2018#) then 'FY19 W24'

      elseif ([Calendar Day Level 01] >= #10-13-2018# and [Calendar Day Level 01] <= #10-19-2018#) then 'FY19 W25'

      elseif ([Calendar Day Level 01] >= #10-20-2018# and [Calendar Day Level 01] <= #10-26-2018#) then 'FY19 W26'

      elseif ([Calendar Day Level 01] >= #10-27-2018# and [Calendar Day Level 01] <= #11-02-2018#) then 'FY19 W27'

      elseif ([Calendar Day Level 01] >= #11-03-2018# and [Calendar Day Level 01] <= #11-09-2018#) then 'FY19 W28'

      elseif ([Calendar Day Level 01] >= #11-10-2018# and [Calendar Day Level 01] <= #11-16-2018#) then 'FY19 W29'

      elseif ([Calendar Day Level 01] >= #11-17-2018# and [Calendar Day Level 01] <= #11-23-2018#) then 'FY19 W30'

      elseif ([Calendar Day Level 01] >= #11-24-2018# and [Calendar Day Level 01] <= #11-30-2018#) then 'FY19 W31'

      elseif ([Calendar Day Level 01] >= #12-01-2018# and [Calendar Day Level 01] <= #12-07-2018#) then 'FY19 W32'

      elseif ([Calendar Day Level 01] >= #12-08-2018# and [Calendar Day Level 01] <= #12-14-2018#) then 'FY19 W33'

      elseif ([Calendar Day Level 01] >= #12-15-2018# and [Calendar Day Level 01] <= #12-21-2018#) then 'FY19 W34'

      elseif ([Calendar Day Level 01] >= #12-22-2018# and [Calendar Day Level 01] <= #12-28-2018#) then 'FY19 W35'

      elseif ([Calendar Day Level 01] >= #12-29-2018# and [Calendar Day Level 01] <= #01-04-2019#) then 'FY19 W36'

      elseif ([Calendar Day Level 01] >= #01-05-2019# and [Calendar Day Level 01] <= #01-11-2019#) then 'FY19 W37'

      elseif ([Calendar Day Level 01] >= #01-12-2019# and [Calendar Day Level 01] <= #01-18-2019#) then 'FY19 W38'

      elseif ([Calendar Day Level 01] >= #01-19-2019# and [Calendar Day Level 01] <= #01-25-2019#) then 'FY19 W39'

      elseif ([Calendar Day Level 01] >= #01-26-2019# and [Calendar Day Level 01] <= #02-01-2019#) then 'FY19 W40'

      elseif ([Calendar Day Level 01] >= #02-02-2019# and [Calendar Day Level 01] <= #02-08-2019#) then 'FY19 W41'

      elseif ([Calendar Day Level 01] >= #02-09-2019# and [Calendar Day Level 01] <= #02-15-2019#) then 'FY19 W42'

      elseif ([Calendar Day Level 01] >= #02-16-2019# and [Calendar Day Level 01] <= #02-22-2019#) then 'FY19 W43'

      elseif ([Calendar Day Level 01] >= #02-23-2019# and [Calendar Day Level 01] <= #03-01-2019#) then 'FY19 W44'

      elseif ([Calendar Day Level 01] >= #03-02-2019# and [Calendar Day Level 01] <= #03-08-2019#) then 'FY19 W45'

      elseif ([Calendar Day Level 01] >= #03-09-2019# and [Calendar Day Level 01] <= #03-15-2019#) then 'FY19 W46'

      elseif ([Calendar Day Level 01] >= #03-16-2019# and [Calendar Day Level 01] <= #03-22-2019#) then 'FY19 W47'

      elseif ([Calendar Day Level 01] >= #03-23-2019# and [Calendar Day Level 01] <= #03-29-2019#) then 'FY19 W48'

      elseif ([Calendar Day Level 01] >= #03-30-2019# and [Calendar Day Level 01] <= #04-05-2019#) then 'FY19 W49'

      elseif ([Calendar Day Level 01] >= #04-06-2019# and [Calendar Day Level 01] <= #04-12-2019#) then 'FY19 W50'

      elseif ([Calendar Day Level 01] >= #04-13-2019# and [Calendar Day Level 01] <= #04-19-2019#) then 'FY19 W51'

      else 'FY19 W52'

      END