diff --git a/public/app/plugins/datasource/elasticsearch/bucket_agg.js b/public/app/plugins/datasource/elasticsearch/bucket_agg.js
index 43ef4f91ab7..38f7eed056c 100644
--- a/public/app/plugins/datasource/elasticsearch/bucket_agg.js
+++ b/public/app/plugins/datasource/elasticsearch/bucket_agg.js
@@ -73,7 +73,7 @@ function (angular, _, queryDef) {
$scope.validateModel = function() {
$scope.index = _.indexOf(bucketAggs, $scope.agg);
$scope.isFirst = $scope.index === 0;
- $scope.isLast = $scope.index === bucketAggs.length - 1;
+ $scope.bucketAggCount = bucketAggs.length;
var settingsLinkText = "";
var settings = $scope.agg.settings || {};
diff --git a/public/app/plugins/datasource/elasticsearch/partials/bucket_agg.html b/public/app/plugins/datasource/elasticsearch/partials/bucket_agg.html
index e3e6cd6f5ff..f94cf99939a 100644
--- a/public/app/plugins/datasource/elasticsearch/partials/bucket_agg.html
+++ b/public/app/plugins/datasource/elasticsearch/partials/bucket_agg.html
@@ -23,7 +23,7 @@
-