anchor.diff:                        {alias_target(Target, Aliases), Values}
                 end, Series);
   
  +% averageAbove
  +evaluate_call(<<"averageAbove">>, [Series, Avg], _From, _Until, _Now) ->
  +    lists:filter(fun({_, Values}) -> safe_average(Values) >= Avg end, Series);
  +
  +% averageBelow
  +evaluate_call(<<"averageBelow">>, [Series, Avg], _From, _Until, _Now) ->
  +    lists:filter(fun({_, Values}) -> safe_average(Values) =< Avg end, Series);
  +
   evaluate_call(Unknown, _Args, _From, _Until, _Now) ->
       lager:error("unknown function call ~p or invalid arguments", [Unknown]),
       error.
  
positive.code:      ?_assertEqual(<<"foo">>, alias_target(<<"foo.bar.test">>, [0]))
      ].
  
  -endif.
  
negative.code:     lists:foldr(F, <<>>, Parts).
  
  
  safe_average(Values) ->
      safe_average(Values, 1, 0.0).
  
  safe_average([], _Cnt, Avg) -> Avg;
  safe_average([{_TS, null} | Vs], Cnt, Avg) ->
      safe_average(Vs, Cnt, Avg);
  safe_average([{_TS, Val} | Vs], Cnt, Avg) ->
      NewAvg = Avg + (Val - Avg) / Cnt,
      safe_average(Vs, Cnt + 1, NewAvg);
  safe_average([null | Vs], Cnt, Avg) ->
      safe_average(Vs, Cnt, Avg);
  safe_average([Val | Vs], Cnt, Avg) ->
      NewAvg = Avg + (Val - Avg) / Cnt,
      safe_average(Vs, Cnt + 1, NewAvg).
  
  
  %%
  %% TESTS
  %%
  