# Bionic Rule Trend Calculation

The trend calculation function lives on the Bionic Rule Transformation Task, when you click +Formula. It can be used to find the trend in a metric over a defined period. A few use cases include finding trends in usage metrics or support cases.

Trend Template (Non Percent):

Taking below sample setup with rule date of 1/9

Trend(Period ( DAYS , 2 ), Clicks , Data Date , AVG , 2 , false )

Data Set

 Data Date (Current Date to Older) Clicks 1/8 1 1/7 0 1/6 1 1/5 1 1/4 1 1/3 0 1/2 0 1/1 1

This is how the calculation generally works using the above information.

Past 2 Days AVG minus Prior 4 Days AVG = Trend

Period Length 2 x Prior Period 2 = 4 Prior Days.

Getting Past 2 Days (1/8 - 1/7):

1 + 0       1

--------  = ----- = . 5

2           2

Getting Prior 4 Days (1/6 - 1/1):

1 + 1 + 1 + 0 + 0 + 1        4

---------------------------- = ------- = Approx. ~ .67

6                        6

Trend

.5 - .67 = -.17

#### Alternative Options

Examples below use the same sample data above.

If Trend Percent is Used,  (( Trend / Prior Period ) *100) (In this example, it’s prior 4 days)

-.17 / .67 = -.2537 * 100 = - 25.37%

If setting “true” to adjust for missing data:

Getting Past 2 Days (1/8 - 1/7):

1           1

--------  = ----- = 1

1           1

Getting Prior 4 Days (1/6 - 1/1):

1 + 1 + 1 + 1               4

---------------------------- = ------- =  1

4                        4

Trend = 1 - 1 = 0

Trend Percent = 0 / 1 = 0%