These id1,id2,etc.. are actually IIDs. If you only have 2 instances of the object on your layout, their IIDs will be 0 and 1. So you can use:
distance(Sprite(0).x, Sprite(0).y, Sprite(1).x, Sprite(1).y)
.
If you have many instances and need to know the distance between any two, you'll need to find their IIDs first.
Alternatively, you can create a family with this sprite and do this:
Pick Sprite instance
Pick Family instance
if distance(Sprite.x, Sprite.y, Family.x, Family.y) ....