diff --git a/frontends/php/include/triggers.inc.php b/frontends/php/include/triggers.inc.php
index 007a7f6..79dfb37 100644
--- a/frontends/php/include/triggers.inc.php
+++ b/frontends/php/include/triggers.inc.php
@@ -200,6 +200,7 @@
 		);
 
 		$ZBX_TR_EXPR_ALLOWED_FUNCTIONS['sum'] = $ZBX_TR_EXPR_ALLOWED_FUNCTIONS['avg'];
+		$ZBX_TR_EXPR_ALLOWED_FUNCTIONS['trend'] = $ZBX_TR_EXPR_ALLOWED_FUNCTIONS['avg'];
 
 		$ZBX_TR_EXPR_ALLOWED_FUNCTIONS['time'] = array(
 			'args' => $args_ignored,
diff --git a/frontends/php/popup_trexpr.php b/frontends/php/popup_trexpr.php
index 1e63a5b..aa07fb1 100644
--- a/frontends/php/popup_trexpr.php
+++ b/frontends/php/popup_trexpr.php
@@ -256,6 +256,12 @@
 			'params' => $param1_sec,
 			'allowed_types' => $allowed_types_any
 		),
+		'trend'		=> array(
+			'description'	=> 'Trend of values for period of time T {OP} N',
+			'operators'     => $operators,
+			'params'	=> $param1_sec_count,
+			'allowed_types' => $allowed_types_numeric
+		),
 	);
 
 
diff --git a/src/libs/zbxserver/evalfunc.c b/src/libs/zbxserver/evalfunc.c
index 927679b..3495a01 100644
--- a/src/libs/zbxserver/evalfunc.c
+++ b/src/libs/zbxserver/evalfunc.c
@@ -1948,6 +1948,128 @@ clean:
 
 /******************************************************************************
  *                                                                            *
+ * Function: evaluate_TREND                                                   *
+ *                                                                            *
+ * Purpose: evaluate function 'trend' for the item                            *
+ *                                                                            *
+ * Parameters: item - item (performance metric)                               *
+ *             parameters - number of seconds/values and time shift (optional)*
+ *                                                                            *
+ * Return value: SUCCEED - evaluated successfully, result is stored in 'value'*
+ *               FAIL - failed to evaluate function                           *
+ *                                                                            *
+ * Author: MiHu                                                               *
+ *                                                                            *
+ * Comments:                                                                  *
+ *                                                                            *
+ ******************************************************************************/
+static int	evaluate_TREND(char *value, DB_ITEM *item, const char *function, const char *parameters, time_t now)
+{
+	const char	*__function_name = "evaluate_TREND";
+	DB_RESULT	result;
+	DB_ROW		row;
+	char		sql[MAX_STRING_LEN];
+	int		nparams, arg1, flag, rows = 0, res = FAIL;
+	double		trend, sum_x = 0, sum_y = 0, sum_xx = 0, sum_xy = 0;
+	double		dx, dy;
+	zbx_uint64_t	lx, ly;
+
+	zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __function_name);
+
+	if (ITEM_VALUE_TYPE_FLOAT != item->value_type && ITEM_VALUE_TYPE_UINT64 != item->value_type)
+		goto clean;
+
+	if (2 < (nparams = num_param(parameters)))
+		goto clean;
+
+	if (FAIL == get_function_parameter_uint(item, parameters, 1, &arg1, &flag))
+		goto clean;
+
+	if (2 == nparams)
+	{
+		int	time_shift, time_shift_flag;
+
+		if (FAIL == get_function_parameter_uint(item, parameters, 2, &time_shift, &time_shift_flag))
+			goto clean;
+		if (ZBX_FLAG_SEC != time_shift_flag)
+			goto clean;
+
+		now -= time_shift;
+	}
+
+	if (ZBX_FLAG_SEC == flag)
+	{
+		result = DBselect(
+				"select clock, value"
+				" from %s"
+				" where clock<=%d"
+					" and clock>%d"
+					" and itemid=" ZBX_FS_UI64,
+				get_table_by_value_type(item->value_type),
+				now,
+				now - arg1,
+				item->itemid);
+
+	}
+	else if (ZBX_FLAG_VALUES == flag)
+	{
+		zbx_snprintf(sql, sizeof(sql),
+				"select clock, value"
+				" from %s"
+				" where itemid=" ZBX_FS_UI64
+					" and clock<=%d"
+				" order by clock desc",
+				get_table_by_value_type(item->value_type),
+				item->itemid,
+				now);
+
+		result = DBselectN(sql, arg1);
+	}
+
+	if (ITEM_VALUE_TYPE_UINT64 == item->value_type)
+	{
+		while (NULL != (row = DBfetch(result)))
+		{
+			ZBX_STR2UINT64(lx, row[0]);
+			ZBX_STR2UINT64(ly, row[1]);
+			sum_x += lx;
+			sum_y += ly;
+			sum_xx += lx * lx;
+			sum_xy += lx * ly;
+			rows++;
+		}
+	}
+	else
+	{
+		while (NULL != (row = DBfetch(result)))
+		{
+			dx = atof(row[0]);
+			dy = atof(row[1]);
+			sum_x += dx;
+			sum_y += dy;
+			sum_xx += dx * dx;
+			sum_xy += dx * dy;
+			rows++;
+		}
+	}
+	DBfree_result(result);
+
+	if (0 == rows)
+		zabbix_log(LOG_LEVEL_DEBUG, "Result for TREND is empty");
+	else
+	{
+		trend = (rows * sum_xy - sum_x * sum_y) / (rows * sum_xx - sum_x * sum_x);
+		zbx_snprintf(value, MAX_BUFFER_LEN, ZBX_FS_DBL, trend);
+		res = SUCCEED;
+	}
+clean:
+	zabbix_log(LOG_LEVEL_DEBUG, "End of %s():%s", __function_name, zbx_result_string(res));
+
+	return res;
+}
+
+/******************************************************************************
+ *                                                                            *
  * Function: evaluate_function                                                *
  *                                                                            *
  * Purpose: evaluate function                                                 *
@@ -2073,6 +2195,10 @@ int	evaluate_function(char *value, DB_ITEM *item, const char *function, const ch
 	{
 		ret = evaluate_LOGSOURCE(value, item, function, parameter, now);
 	}
+	else if (0 == strcmp(function, "trend"))
+	{
+		ret = evaluate_TREND(value, item, function, parameter, now);
+	}
 	else
 	{
 		zabbix_log(LOG_LEVEL_WARNING, "Unsupported function:%s",
