def get_trend(timeseries):
    """
    Using the values returned by get_timeseries(), compare the current
    Metric value with it's previous period's value

    :param timeseries: data returned from the get_timeseries() method
    :returns: the last period value and relative change
    """

    last = timeseries['value'][len(timeseries['value']) - 1]
    prev = timeseries['value'][len(timeseries['value']) - 2]
    trend = last - prev
    trend_percentage = None

    if last == 0:
        if prev > 0:
            trend_percentage = -100
        else:
            trend_percentage = 0
    else:
        trend_percentage = int((trend / last) * 100)
    return (last, trend_percentage)
Using the values returned by get_timeseries(), compare the current
    Metric value with it's previous period's value

    :param timeseries: data returned from the get_timeseries() method
    :returns: the last period value and relative change