Select merge with joins and count

so how can i pass the field dynamically in the select merge . If I pass it like this:

“id”

^String.to_atom(id) => x.id

It gives me error that it expects a binary. But if i use the field like this:

“id” => x.id
It gives me error that id is not present in the struct.

It only works if i hard code it like this:

id: x.id

So any work around for dynamic interpolation of the key.

Thanks