Hi Elizabeth,
You could try an approach like this:
1) In your BEx Query, create a Formula Variable based on dimension Instance
2) Create a Calculated Key Figure based on the formula variable and set Calculate Single Values as Maximum
3) Apply the getDataAsString() method to obtain the value of the Calculated Key Figure in 2
4) Apply setFilter("Instance", value from Step 3)
Regards,
Mustafa.