In stored calc expression, how to filter by a variable

entity type TypeA schema name "ex" {
     otherTypes: [OtherType] (parent)
     date: datetime
     // count: int stored calc "count(otherTypes.(timestamp > date))"
}

In the example above, I want count to be the number of otherTypes with timestamp after date variable in TypeA. How do I write the expression?

1 Like

What happens when you try that?

When I provision, it generates this warning:

“Calc field count in type TypeA references field date which is not defined in type OtherType or any of its extension types”,targetType:“TypeA”,targetField:“count”}

Yes, that’s an unavoidable warning (shouldn’t be an error) because we do “fuzzy” matching of the field “date” up the chain from the dot query. Try a test case and see if it works. If so, the warning is a known issue that we will eventually fix but probably not until we replace the expression engine used by stored calcs

It does work. Thank you!