How to access query dimensions from schema definitions

Hi, is there any way I could access query dimensions to make BQ analytics query working like:

  sql: `PERCENTILE_CONT(x, 0.5) OVER (${QUERY_CONTEXT.dimensions})`

Best regards!

Hi @Danilo_Mota :wave: Could you please elaborate? What would you like to see as inputs and what kind of result you’d like to get?

Hi @igorlukanin , I’m trying to create a measure for median values using the BQ percentile function.

The simplest way I figure out how to accomplish this is using the query’s dimensions as a PARTITION BY statement inside the OVER clause.

sql: PERCENTILE_CONT(price, 0.5) OVER (PARTITION BY ${QUERY_CONTEXT.dimensions})

Where ${QUERY_CONTEXT.dimensions} would inject the dimensions sent by client.

It looks like defining a measure as PERCENTILE_CONT(price, 0.5) and a number of dimensions in the schema and then querying that measure and all dimensions should do the job. Please feel free to follow up if this approach doesn’t work for you.