Trendline values using Dynamic Range in Excel - comparing with LINEST function

Scoop9212

New Member
Joined
Feb 23, 2024
Messages
1
Office Version
  1. 2019
Platform
  1. Windows
Hello,
I'm going to first explain in detail what I'm getting so that there's not confusion.
I have the following data in subsequent columns: time(s), volume(cm3), volume(m3), time/volume(s/m3).
So, as you can see, the first 2 columns are 'input type columns', in which I insert the values from experiments. The last 2 columns are calculated values based on those 2 columns. The inputs from the first 2 columns are collected from a DATA tab I set up to easily insert all experiments data.
My initial ideal was to have a DATA-tab to add all experimental data and 1 DISPLAY-tab to show the data organized and with all the plots.
To do that, I added a dropdown list with the name of the experiments and as I select one experiment, all the experimental data from the DATA-tab is displayed in the DISPLAY-tab and all the graphs and calculated values are displayed accordingly. That works just fine. However, one piece of data does not, which is the one I described above. That is because I have a table containing those 4 columns with each 42 rows (which is the max a experiment can go, but often the values are fewer than that). So, when I select, for example, experiment 1, the table displays values in 32 rows, but not in the rows below those. In fact, in the first 2 rows, which are the ones collecting data from DATA-tab, it's all 0s, the volume(m3) column it's all 0s as well due to the formula used. However, the t/V column it's all '#DIV/0!' values, because the calculation divides by 0, which is not possible, giving it this error message.
With this data, I plot t/V vs. V (which is 'time/volume(s/m3)' vs. 'volume(m3)'). In this graph, I use the linear regression Excel function to give me the equation 'y=mx+b'. As I will use the 'm' and 'b' values, on the cells below the graph I use the LINEST function to give me the 'm' and 'b' values of the range.
.
And now comes the issue: everytime I change the experiment, the amount of data changes in the first 2 columns and so the problem with the 0s and error messages described above arrises.
If I build a plot selecting the whole range of the 42 rows, my graph will plot fine, but the regression data shown in the plot will be wrong. I know that because (1) when I adjust the range manually to the cells containing valid data, the values of the equation change, and (2) the LINEST values are different from the plot when the whole range is selected, but it agrees with the range manually changed to contain only valid data.
Also, I want the LINEST function range to also change as the data changes, because it gives me an error when there's '#DIV/0!' error messages in the range, or even if there's empty cells. LINEST will only work when the valid data is in the cells in which the range is set up to.
.
I tried the Dynamic Array set up, but it didn't seem to work. Can someone help me with that?
.
Basically what a want is to:
1. Have a plot that changes its range of plotted data as the values in the corresponding range changes, to display and use for calculation values that don't include zeroes or error values;
2. Have a LINEST function to work with variable range.
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
First, convert your range into a Table (Ribbon >> Insert >> Tables >> Table) so that you can use structured references to refer to the data. Structured refefrences automatically adjust as data is added or removed from the table. Then use the FILTER function for both arguments of the LINEST function to exclude empty cells and cells containing error values. Here's an example...

scoop.xlsm
ABCDEF
1Known YKnown XResult (slope)Result (y-intercept)
21021
3
494
5#DIV/0!#DIV/0!
652
773
8
Sheet1
Cell Formulas
RangeFormula
D2:E2D2=LINEST(FILTER(Table1[Known Y],(ISNUMBER(Table1[Known Y]))),FILTER(Table1[Known X],(ISNUMBER(Table1[Known X]))),,FALSE)
Dynamic array formulas.


Hope this helps!
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,959
Members
449,096
Latest member
Anshu121

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top