Is there a way to create a text field listing the slope of trend lines? (I am much more interested in the slope, but if it is possible, I'd like to know if p-value is also available as a text field)

I have many different customers purchasing habits over time in a line graph with trend lines. I'd like to create a table showing the trend lines' slopes (and possibly p-values) so they can be sorted in the table by what business is declining and what is growing.

Do you want to do this automagically or one trend line at a time interactively? There are some ways to do this kind of thing, but the route depends on how the visualizations will be consumed or used. Can you provide a bit more information?

The trendline slopes I'd like to see are those of about 55 different customers which are shown on one line graph (I know that's a lot for one graph, but I have it set up so they're highlighted when I click in the adjacent table)

I know I can hover over the trendline and it shows the slope, and I know you can describe the trend model by right clicking on the chart. However, this is not useful to me.

What I want is to have a calculated field that presents the all 55 trendline slopes as numbers next to in a table.

I wanted to bump this as well because I have a similar scenario. I am trying to create an optimal pricing model so if I use the base trend line it's no good because my customers with poor margins bring down the trend. I would like to be able to adjust and calculate a line and plug in that formula and at the minimum have Tableau draw it for me (at maximum be able to use it in calculated fields). Right now I am having to export it out as an image and using a photo editor to draw the line.

With custom table calculations, I believe what you are looking can be done, but you would need to provide sample data, and the formulas and/or business logic you want applied, and what you expect for a result. With additional details and specifics on what you have and what you are looking for, assistance can be provided.

There seems to be a lot of interest in being able to calculate the slope for a linear regression in Tableau above and beyond the built in trend line. This makes sense as sometimes you might want to sort or isolate things with certain slopes. I would give this calculation a shot:

For time series it might be a little more difficult. If you have data by day, I might try making your [x] field something like: datediff('day',today(),[Date]) assuming you don't have data going out into the future. If you do, you can just anchor the datediff calc to a random date in the past before your data starts (datediff('day',date(1/1/1998),[Date])).

EDIT: or you can just be smart and create a field float([Date]) and use that instead

This should pull out your slope value. You can back into your intercept and rsquared with similar logic.

Remember that this is a table calculation so if you are looking to slice this up by a dimension will most likely need to edit your table calc to restart every [dimension] (and change the compute using).

I have a very similar case, but can't seem to get the formula to provide the right answer.

I'm attaching a sample .twbx

For the data that's in there, Tableau is calculating a slope of .224237 when I bring in a linear trend line. I want to create a calculated field that will return that same result, but I have been unable to get the same result using your guidance above. I think it might be related to fact that my Y value is already an AGG function. If you could take a look, I would really appreciate it. Let me know if you have any questions.

Y should be Unit Price

X should be Year

*I have multiple records in a given year, so that's why my unit price is already a AGG function: sum([Net value])/SUM([Order Quantity])