Grafana Data link is not working properly in version 10.2 and 10.3

I upgraded my grafana docker instance from version 9.5 to 10.2. The data link is not working properly, which is working fine in version 9.5.
The below is the postgresql query I’m using

SELECT id, metric_time, metric_type,  metric_val_json
FROM q_metric where  tenant_name = ${tenantname}
and metric_type ='Test Stats'
and metric_time between $__timeFrom() and $__timeTo() 

I’m using data link to navigate to other dashboard to see some details
Here is the data link
The problem is the value of var-qm_id=${} in the url after data link click is not getting substituted with id of the point clicked, instead it is getting replaced by some other value of id in the graph. The problem does not occur in old 9.5 version.
Can anyone please help me with this.