How to create a pivot chart with variable?

I created question "73" that uses the variable "company_entity_id" as below:

I'm able to send a value for this variable as a param when calling this question from React and it works just fine.

My actual need is to display the question in the pivot form. I understand that I won't be able to use a pivot chart with raw SQL in question "73".

Therefore I created question "74" based on "73" like the following:

Now the issue is I don't know how to instruct question "74" to use a variable for the value "company_entity_id" .

How do I do this?
My output should be like the following. Currently it's displaying with the hardcoded value for "company_entity_id". I need to actually assign a value to "company_entity_id" by sending it from React as a param.

Any assistance is very much appreaciated. I've been looking at it the whole day.

Hey there, just an idea:

what about including your whole query into a Metabase Model, and then building your pivot with filters on top of that model?

You could have a simple query like this:

FROM your_metabase_model
WHERE {{your_filter_based_on_a_column}}

This could allow you to separate the model logic from the visualisation logic.

Hope this help!