2 Replies Latest reply on Feb 15, 2017 5:03 PM by Joan Armande

    Determine Trend slope coefficient across parametrized date range

    Joan Armande

      I've been working with the posting by Jonathan Drummey that explains how to generate the slope coefficient of a trend. Here it is: Re: How can I find the up or down direction of a Trend Line?

       

      I have a workbook showing workbook views and views trend over a parameter date range.  Basically, I'd like use the slope coefficient in another calculation that shows a KPI for whether the trend is up or down for the date range selected. However, I can see that the slope returned by my calc doesn't always match the slope of the trend line in the chart I'm checking it against. For example my slope calc returns a negative value when the trend in the chart shows positive.

      Final Screen_Shot_2017-02-15_at_4_06_04_PM.jpg

       

      Based on other threads, I think my problem lies either with the LOD I have in place or has something to do with the date parameters since Jonathan's posting doesn't address that specifically.

       

      Can anyone help identify the issue and how to fix? I've simplified the workbook to help...

        • 1. Re: Determine Trend slope coefficient across parametrized date range
          Jonathan Drummey

          Hi Joan,

           

          The problem is that since the workbook is using the FIXED method from Re: How can I find the up or down direction of a Trend Line? <https://community.tableau.com/message/387612#387612> we must use context filters, otherwise the FIXED LODs are computed before the filters are applied. Here’s the relevant set of notes from my original post:

           

           

          A FIXED vs. INCLUDE/EXCLUDE tangent:

           

          When I first started using LOD expressions I was all about the FIXED. With a little more practice now I generally prefer using INCLUDE & EXCLUDE. There are two reasons why:

           

          - FIXED calcs are invariant to the dimensions in the view. If I want to swap out Customer Segment for Region & Order Priority then I've got to make a number of edits, whereas in the INCLUDE/EXCLUDE option (still to come) or table calculation solution all I need to do is drag & drop pills.

           

          - FIXED calcs are only filtered by context filters & data source filters, so I have to remember (or in the case of helping others remind them) to turn any existing filters into context & data source filters. That's an extra set of steps that break my analytical flow.

           

          I haven’t evaluated every calculation to make sure that they are right, however here’s a screenshot showing that when I add all the filters to context the Slope calc is returning -0.1807 vs. the Tableau trend line of -0.1811, so they are pretty close!

           

          Jonathan

          • 2. Re: Determine Trend slope coefficient across parametrized date range
            Joan Armande

            Okay thanks Jonathan -- The context filter reference must have been obscured by all the math I was taking in!

             

            Thanks for that original post!!