       timeFilter: filter
     }
 
-addToFilter = (filter, newFilterPiece) ->
+addToFilter = (filter, newFilterPieces...) ->
   if filter?
-    if newFilterPiece.type is 'within'
+    newTimeFilterPiece = newFilterPieces.filter(({type}) -> return type is 'within')[0]
+    if newTimeFilterPiece?.type is 'within'
       { filter, timeFilter } = separateTimeFilter(filter)
-
+    newFilterPieces.push filter
+  if newFilterPieces.length > 1
     return {
       type: 'and'
       operation: 'filter'
-      filters: [newFilterPiece, filter]
-    }
-  return newFilterPiece
+      filters: newFilterPieces
+    }
+  return newFilterPieces[0]
 
 createFilter = (value, splitOp) ->
   if splitOp.bucket in ['timePeriod', 'timeDuration']


      if condensedCommand.applies?
        for apply in condensedCommand.applies
          exists = checkDeep(root, 0, i, apply.name, condensedCommand.split.bucketFilter)
          if not exists
            added = true


splitToHash = (split) ->
  hash = []
  for own k, v of split
    continue if k in ['name', 'bucketFilter']
    hash.push(k + ":" + v)

  return hash.sort().join('|')
