To query a field which name is contained in a variable, use the field function.
some_field = :id some_value = 10 from p in Post, where: field(p, ^some_field) == ^some_value