1 Reply Latest reply on Sep 14, 2012 10:47 AM by Tracy Rodgers

    Case and if statement

    Amoryn Saayman

      how can i use a case and if statement in the same calculated field?

        • 1. Re: Case and if statement
          Tracy Rodgers

          Hi Amoryn,

           

          Here is an example of using both the case and if functions in the same calculation:

           

          case [Time Period]

          when "This Month" then (if datepart('month', [Order Date])=datepart('month', today()) then [Tweet date]  end)

          when "Last Month" then (if datepart('month', [Order Date])=datepart('month', (dateadd('month', -1, today()))) then [Tweet date] end)

          when "Last 6 Months" then (if datepart('month', [Order Date])=datepart('month', (dateadd('month', -6, today()))) then [Tweet date] end)

          when 'This Quarter' then (if datepart('quarter', [Order Date])=datepart('quarter', today()) then [Tweet date] end)

          when "Last Quarter" then (if datepart('quarter', [Order Date)=datepart('quarter', (dateadd('quarter', -2, today()))) then [Tweet date] end)

          when 'This Year' then (if datepart('year', [Order Date])=datepart('year', today()) then [Tweet date] end)

          end

           

          Hope this helps!

           

          -Tracy