Add Expression for Entity Query
I am not sure if following is what you're looking for, it helped me when I was doing something similar
$sql_snippet = &lt;&lt;&lt;EOF

ROUND(
CASE $this-&gt;tableAlias.$unit_column
WHEN 'kg' THEN $this-&gt;tableAlias.$this-&gt;realField * :kg_coefficient
WHEN 'lb' THEN $this-&gt;tableAlias.$this-&gt;realField * :lb_coefficient
END
, :precision) = :value
EOF;
// The difference in this invocation of ::addWhereExpression() compared to
// the invocation in the filter handler is that here part of the DB
// placeholders come from $this-&gt;options (such as precision) and others come
// from the actual argument we have received, i.e. derived from
// $this-&gt;argument.
$this-&gt;query-&gt;addWhereExpression(0, $sql_snippet, [
  ':value' =&gt; round($arg['value'], $this-&gt;options['precision']),
  ':kg_coefficient' =&gt; $kg_coefficient,
  ':lb_coefficient' =&gt; $lb_coefficient,
  ':precision' =&gt; $this-&gt;options['precision'],
]);

}
Lifted from Here