1 Reply Latest reply on Oct 16, 2018 4:45 PM by Deepak Rai

    If statement for YoY % and MoM % not working

    Aaron Oyer

      Hi everyone,

       

      I'm new to the forums and to tableau until just recently (be gentle )

       

      I am wanting to use an area chart to examine our Quotes. I want the chart to show SEO quotes stacked on top of (Total-SEO) which I refer to as Other_Quotes

       

      I have Quotes (metric) and Channel (SEO or total) as a dimension.

       

      SEO_Quotes =

      IF([Channel]='SEO')

      THEN([Quotes])

      ELSE(0)

      END

       

      Total_Quotes =

      IF([Channel]='Total')

      THEN([Quotes])

      ELSE(0)

      END

       

      Other_Quotes = [Total_Quotes]-[SEO_Quotes]

       

      I used these new fields to create an area chart with SEO and Other quotes on a monthly basis. I now want MoM % and YoY % in the tool tip for both SEO and Other.

       

      Here is the calc I attempted to use:

      IF  Attr([Product]="SEO")

      THEN((sum([SEO_Quotes])-lookup(sum([SEO_Quotes]),-1))/(lookup(sum([SEO_Quotes]),-1)))

      ELSE((sum([Other_Quotes])-lookup(sum([Other_Quotes]),-1))/(lookup(sum([Other_Quotes]),-1)))

      END

       

      The above calc is showing correct MoM % for Other_Quotes but for SEO_Quotes it is showing the same percentage as Other_Quotes which is obviously wrong for our SEO traffic.

       

      I would love to post the workbook but company rules prevent it.

       

      Any help is appreciated, thank you!