Expression matching multiple criteria

#1

How can I build an expression for a stored calc that matches multiple criteria? Here’s a concrete example:
SuckerRodPump has a field tests: [WellTest], and each WellTest has a double field oilRate and boolean isAllocatable. I’d like to return back the first allocatable oil rate value.

This projection gets me the earliest value:

c3Grid(SuckerRodWell.evaluate({
  limit: 10, 
  projection: "id, earliestValue(tests.oilRate.value)"
}))

and I’m looking for something along the lines of:

c3Grid(SuckerRodWell.evaluate({
  limit: 10, 
  projection: "id, earliestValue(tests.oilRate.value && (tests.isAllocatable == true))"
}))

(which, as expected, just returns a boolean value)

0 Likes

#2

Try adding a filter to the evaluate call. Along the lines of:

c3Grid(SuckerRodWell.evaluate({
filter: “tests.isAllocable == true”,
limit: 10,
projection: “id, earliestValue(tests.oilRate.value”
}))

0 Likes

#3

You can add a filter to the middle of an expression, like this:

c3Grid(SuckerRodWell.evaluate({
  limit: 10, 
  projection: "id, earliestValue(tests.(isAllocatable == true).oilRate.value)"
}))

to include only the WellTest objects whose isAllocatable value is set to true

So the stored calc field can look something like this (untested):

earliestAllocatableOilRate: double stored calc "earliestValue(tests.(isAllocatable == true).oilRate.value)"
2 Likes

#4

Matt - you nailed it. That’s perfect. Thanks!

0 Likes