                 fatalError("*** An error occurred while calculating the statistics: \(error?.localizedDescription) ***")
             }
             var statisticsValues: [Double] = []
-            statsCollection.enumerateStatisticsFromDate(startDate, toDate: endDate, withBlock: { (statistics, stop) in
-                var doubleMaxValue = 0.0
-                switch quantityType.aggregationStyle {
+            if statisticsRange == .Year && quantityType.aggregationStyle == .Cumulative {
+                self.getStatOfYear(statsCollection, quantityType: quantityType, completion: { (statForYear) in
+                    completion(statisticsVlues: statForYear)
+                })
+            } else {
+                statsCollection.enumerateStatisticsFromDate(startDate, toDate: endDate, withBlock: { (statistics, stop) in
+                    var doubleMaxValue = 0.0
+                    switch quantityType.aggregationStyle {
                     case .Discrete:
                         if let maxValue = statistics.averageQuantity() {
                             doubleMaxValue = maxValue.doubleValueForUnit(quantityType.defaultUnit!)

                        if let maxValue = statistics.sumQuantity() {
                            doubleMaxValue = maxValue.doubleValueForUnit(quantityType.defaultUnit!)
                        }
                }
                statisticsValues.append(round(doubleMaxValue))//add max double value
            })
            if statisticsRange == .Year && quantityType.aggregationStyle == .Cumulative {
                self.getSamplesForYear(type, completion: { (numberOfDaysWithSamplesForEachMonth) in
                    for statIndex in 1...statisticsValues.count {
                        let indexOfArray = statIndex - 1
                        let summFoMoth = statisticsValues[indexOfArray]
                        let numOfEventsInMoth = numberOfDaysWithSamplesForEachMonth[indexOfArray]
                        if (summFoMoth > 0 && numOfEventsInMoth > 0) {
                            statisticsValues[indexOfArray] = summFoMoth/numOfEventsInMoth
                        }
                    }
                    completion(statisticsVlues: statisticsValues)
                })
            } else {
                completion(statisticsVlues: statisticsValues)
            }
        }
        healthKitStore.executeQuery(statisticsQuery)
    }
    
    public func getMinMaxValuesForPeriod(statisticsRange: HealthManagerStatisticsRangeType, forType type: String, completion: (statisticsMaxVlues: [Double], statisticsMinVlues: [Double]) -> Void) {
        
        let group = dispatch_group_create()

            startDate = calendar.dateByAddingUnit(.Day, value: -31, toDate: endDate, options: [])!
        case .Year:
            endDate = endDateForYear
            if statisticsOptions == .CumulativeSum {
                interval.day = 1
            } else {
                interval.month = 1
            }
            anchorYearComponents.month -= 11
            anchorComponents = anchorYearComponents
            startDate = calendar.dateByAddingUnit(.Month, value: -11, toDate: endDate, options: [])!
