2 Replies Latest reply on Nov 3, 2019 6:20 AM by Soumitra Godbole

# How do I create a calculated field that calculates slope and intercept of trend line?

Hi,

I am using Tableau version number 2018.3.5 Desktop Professional edition. I attached demo_20191101_14_39.twbx to this post.

In demo_20191101_14_39.twbx worksheet named "Sheet 1", I have a grouped bar graph and trend lines. See screenshot below:

I want to know how to calculate the slope and intercept for one of the trend lines. Please see screen shot below:

I have highlighted in yellow in the screenshot above the values for slope and intercept. Slope = -0.0002369 and intercept = 9.04548.

Can someone show me how to create a calculated field to generate the slope and the intercept? I read this and am still having a hard time figuring this out.

It would help a lot if you can include a step-by-step instruction as well as add a Tableau workbook to this post. If attaching a Tableau workbook, please make sure to use Tableau version number 2018.3.5 or older. Ther reason for this is because I do not have a newer version of Tableau. So, I cannot open the workbook from Tableau versions newer than 2018.3.5.

Any help would be greatly appreciated!

• ###### 1. Re: How do I create a calculated field that calculates slope and intercept of trend line?

Hi Daniel,

You could peruse the following...

or

or

If this answers your question please mark it as correct so that others may find it in their search for a solution in the future.  Best, Don  How to Mark an answer as Correct

We would love to hear your feedback on your Tableau Community Forums experience.

Please take this 5 minute survey.

• ###### 2. Re: How do I create a calculated field that calculates slope and intercept of trend line?

Hello again Daniel,

Looks like I stumbled upon a similar problem (not a duplicate) as I have just solved the other

one asking for the Slope & Y-intercept. I was not sure if it is your earlier post as there may be

several persons with the same first and last name.

Anyway, do check out the post and you will find a really cool solution that enables you to

calculate the slope, y-intercept and only displays selected trendlines (for specific products)

Hope this helps.

Best Wishes,

Sincerely,

Soumitra