Using a variable in Elasticsearch percentiles "values" field

Take a look at this thread

You can do a bit more fancier stuff using infinity plugin with es enpoint. Maybe this can help?