def METHOD_NAME(formulas: QuerySet) -> Q:
    aggregate_formula_ids = []
    for f in formulas:
        try:
            if f.cached_untyped_expression.aggregate:
                aggregate_formula_ids.append(f.id)
        except BaserowFormulaException:
            continue
    return Q(id__in=aggregate_formula_ids)