TREND in ONLYOFFICE Spreadsheet Editor
Fit linear least-squares predictions with explicit x values, intercept choices, multi-predictor shapes and independently verified small datasets.
Verification status: See the evidence and test scope described in this guide. How formula examples are checked
Quick answer: For x values 1,2,3,4 and y values 3,5,6,9, TREND fits y=1.9x+1. Predictions at x=5 and x=6 are independently 10.5 and 12.4.
Availability and evidence scope
- Introduced: Original introduction release is not established by the checked sources.
- Available: Listed in current unversioned ONLYOFFICE help, checked October 18, 2026.
- Implementation inspected: Official SDKJS v10.0.0.169, commit
3679e0375a758d7dc59d31337a45461be3525ed8. The snapshot does not prove identical behavior in every installed editor. - Retired or deprecated: These sources do not establish retirement or formal deprecation.
- Testing: Numerical examples are independent mathematical expectations, and implementation discrepancies are labeled source predictions. No ONLYOFFICE application or calculation-engine execution was performed.
The examples use English function names and commas. Use your locale’s argument separator if different. Retain full precision in formulas; round only the displayed result. Nested output grids describe source-derived array contents. Native spill placement, obstruction errors, array-entry shortcuts and recalculation behavior have not been tested in the application. Reserve a separate output area and follow the array-formula entry method supported by your installed editor; do not assume a particular keyboard shortcut or automatic spill behavior.
Syntax and defaults
=TREND(known_y, [known_x], [new_x], [const])
One to four arguments are registered. known_y contains the responses, known_x the explanatory values, and new_x the positions where fitted responses are requested. TRUE or omitted const estimates an intercept; FALSE forces the intercept to zero and refits the slope. This is not the same as estimating an ordinary line and then erasing its intercept.
When known_x is omitted, the inspected helper generates 1,2,…,N in the known-y layout. When new_x is omitted, predictions are returned at the known x values. Those fitted values may differ from the observed responses. TREND returns predictions, not the slope/intercept array or standard errors; LINEST provides those coefficients and optional statistics.
For one predictor, keep known_x and known_y the same shape. In that case the new_x layout determines the prediction layout: a two-row column of new x values gives a two-row column of predictions. For multiple predictors, use the observation/predictor dimensions described below.
Step-by-step: fit a line with visible residuals
Enter this dataset:
| Worksheet row | A: x | B: y |
|---|---|---|
| 1 | 1 | 3 |
| 2 | 2 | 5 |
| 3 | 3 | 6 |
| 4 | 4 | 9 |
- Put new x values 5 and 6 in D1:D2.
- Evaluate
=TREND(B1:B4,A1:A4,D1:D2,TRUE)in a separate output area. - The independently expected vertical result is 10.5; 12.4.
- To inspect the fit at the original positions, evaluate
=TREND(B1:B4,A1:A4)separately. - The independently expected fitted values are 2.9; 4.8; 6.7; 8.6.
The x mean is 2.5 and y mean is 5.75. Centered cross-products sum to 9.5 and centered x squares to 5, giving slope 9.5/5 = 1.9. The intercept is 5.75−1.9×2.5 = 1. Residuals, observed minus fitted, are 0.1, 0.2, −0.7 and 0.4, with squared sum 0.7. This explains why TREND is fitting a line rather than simply repeating each observation.
Because these x values are exactly 1 through 4, =TREND(B1:B4) happens to produce the same fitted values. That equivalence would not hold if actual x positions were 2,4,8,16 or irregularly spaced times. Omitting x is a substantive assumption about spacing.
Intercept constraint: refit through zero
=TREND(B1:B4,A1:A4,D1:D2,FALSE) uses slope SUM(x*y)/SUM(x^2)=67/30, approximately 2.233333333333, and intercept 0. Predictions at 5 and 6 become 11.166666666667 and 13.4. They are not the unconstrained predictions minus 1.
Force zero only when a zero response at zero explanatory value is part of the intended model. Shifting the origin of x can change the meaning of this constraint. Formatting cells, subtracting a baseline from a label, or hiding a column does not change the numeric model.
Advanced example: two explanatory columns
On a fresh sheet, put predictor pairs (0,0), (1,0), (0,1), (1,1) in A1:B4, and responses 1,3,4,6 in C1:C4. They follow y=1+2*x1+3*x2 exactly. Put the new pair 2,3 in E1:F1 and evaluate =TREND(C1:C4,A1:B4,E1:F1,TRUE). The independent prediction is 14.
With known_y as a column, observations run down rows and each known_x column is a predictor. New observations must contain the same number of predictor columns. If known_y is a row, the analogous arrangement uses predictor rows and observation columns. Do not transpose only one side of the data. The simple one-predictor case permits same-shaped x/y matrices; that should not be confused with a multi-predictor design.
Errors, degeneracy and interpretation
The shared source validator checks incompatible known-x/known-y dimensions before their element types, returning internal bad_reference, conventionally #REF!. For example a three-row y range and two-row x range predict a shape error. Nonnumeric elements in compatible training matrices predict wrong_value_type (#VALUE!); they are not silently dropped as complete observations. New-x elements must also be numeric. Keep labels outside the selected ranges.
A multiple-predictor new-x shape mismatch leads to no usable helper result and the wrapper predicts #VALUE!. QR decomposition failure or an exactly zero diagonal can also fail. Near-dependent predictors may be unstable without producing an obvious error; the source does not establish a general robust rank-reduction guarantee.
For simple regression with all x values identical, the inspected helper replaces a zero x-square denominator with 1. With an intercept this yields slope 0 and predictions equal to mean y, rather than proving a meaningful trend. Do not treat a numeric answer as evidence that the design identifies a slope.
Least-squares predictions describe the chosen linear model. They are not causal evidence, prediction intervals or guaranteed future outcomes. Inspect residuals and the observation process; extrapolating x=5 or 6 beyond training x=1..4 assumes the relationship continues. Correlated errors, changing variance, outliers or a curved relationship can make a visually plausible line misleading.
Compatibility and related functions
Recalculate representative formulas when moving a workbook between editors. Matching names do not guarantee identical argument coercion, array behavior, numerical precision or error handling. These source-derived examples do not establish automatic spill behavior or a general import/export guarantee.
Official references
- ONLYOFFICE TREND help, checked October 18, 2026.
- Official SDKJS implementation, 2248–2615, tag v10.0.0.169 and exact commit above.