# Timelion Sheet: is a secondary (TL-native) calculation possible

#1

In Timelion is a secondary calculation possible? .trend () of .divide ().
Stated differently, How to calculate trend of Percent, where Percent is calculated using .divide () in Timelion, and is not a Scripted Field.

(Joe Fleming) #2

I believe all you need here is to add a trend at the end. Here's an example, since I can't see what your exact query is:

`````` .es(q=error).divide(.es(q=*)).trend()
``````

This will query error documents, divide them by the total and provide a percentage of errors, and then give you the linear regression of the percentage value over time.

#3

Yes, while .trend() at end displays the linear regression line, we at the same time lose the .divide() tabulated Percent line of the raw data.

1. Is there a way to display both the tabulated Percent line and Trend in the same TL graph
2. Is there a Function for Polynomial Regression, or only Linear?

Thank you!

#4
1. Resolved: At the end of the initial .es(q=error).divide(.es(q=)) appended a complete .es(q=error).divide(.es(q=)).trend(). This displays both Percent and Trend lines on the same graph

2. Is there a Function for Polynomial Regression, or only Linear?

(Joe Fleming) #5

As far as I know there's only a linear regression function, but I'm not the most well-versed Timelion user, so I could be wrong. I've asked someone else on the team that knows more about it, and I'll let you know what I learn.

UPDATE: poking through the code a little, it looks like `.trend()` has a logarithmic mode. I'm basing that on this bit of code, which define the valid values for `mode`.

UPDATE 2: perhaps you already know this, but just in case, you can find the trend function's docs here: https://github.com/elastic/timelion/blob/master/FUNCTIONS.md#trend

(system) closed #6

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.