4 Replies Latest reply on Dec 3, 2018 8:53 AM by Shaquelle Jacobs

    IF statement

    Shaquelle Jacobs

      I want to do a function that would say EXAMPLE. iF THIS MONTH > PREVIOUS MONTH THEN 'pass' ELSE 'fail'. and if assault ytd >  Ytd Previous 'pass' else 'fail'. if 12 months this year > 12 mth previous then 'pass' else 'fail' .

       

        • 1. Re: IF statement
          Ken Flerlage

          Could you attach a sample workbook or sample data set? This all depends on the structure of your data.

          • 2. Re: IF statement
            Shaquelle Jacobs

            due to company policies, i cant, but here are the calculations

             

            this month

            IF DATEDIFF('month',DATETRUNC('month',[Brief Date Time]),{MAX(DATETRUNC('month',[Selected Date]))})=0

            THEN [Number of Records]

            END

            Previous Month

            if

            DATEDIFF('month' ,[Brief Date Time], [Selected Date] ) = 12

            then [Number of Records]

            end

            YTD

            if

            DATEDIFF('year', [Brief Date Time], [Selected Date])=0

            and

            MONTH([Brief Date Time])<= MONTH([Selected Date])

            then

            [Number of Records]

            END

            YTD PREVIOUS

            if

            DATEDIFF('year', [Brief Date Time], [Selected Date])= 1

            and

            MONTH([Brief Date Time])<= MONTH([Selected Date])

            then

            [Number of Records]

            end

            12 MONTHS THIS YEAR

            if [Brief Date Time] >= DATEADD('month',-12,[Selected Date]) + 1 then [Number of Records]

            END

            PREVIOUS 12 MONTHS

             

            if [Brief Date Time] >= DATEADD('month',-24,[Selected Date])+1  and [Brief Date Time] <= DATEADD('month',-12,[Selected Date]) then [Number of Records]

            END

            • 3. Re: IF statement
              Ken Flerlage

              I don't think we'll be able to figure it out from this, unfortunately. Instead of attaching your actual data, could you mock-up a sample data set? Or, could you anonymize your workbook using the following tutorial: Anonymize your Tableau Package Data for Sharing

              • 4. Re: IF statement
                Shaquelle Jacobs

                i am working on it