Aggregate booleans

#1

I have a parent type that has children and those has some attributes that may or not exists.

type Parent {
  children: [Child]
}
type Child {
  att1: decimal
  att2: decimal
}

I want a metric that return true if both att1 and att2 exists in every child for a given parent.

Is there a way to aggregate a collection of booleans? when looking to the ExpressionEngineFunction definition, I see that the method aggregate accepts only SUM|AVG|MIN|MAX !!

I need something like that:

{
  "id": "AwesomeMetric_Parent",
  "name": "AwesomeMetric",
  "srcType": "Parent",
  "path": "children",
  "expression": "aggregate(exists(att1) && exists(att2), 'AND')",
  "description": "Whether parent is awesome or not"
}
0 Likes

#2

I believe, you could write the metric as:

{
  "id": "AwesomeMetric_Parent",
  "name": "AwesomeMetric",
  "srcType": "Parent",
  "path": "children",
  "expression": "and(exists(att1) && exists(att2))",
  "description": "Whether parent is awesome or not"
}
1 Like