Time series line graph based on variable thresholds with transformations

We are using version 10.4.2 of grafana, and want to achive this:

but this is with hardcoded thresholds, we want to use variable thresholds from the query. count is the graph line and t3.threshold is average (orange) and t4.threshold is busy (red)

The query is:

SELECT t1.end_timestamp
, t1.total_count AS count
, t3.threshold AS average
, t4.threshold AS busy
FROM table t1
JOIN
table t2 ON t2.sensor = t1.sensor
JOIN
table t3 ON t2.id = t3.sensor_id AND t3.severity = 1
JOIN
table t4 mt2 ON t2.id = t4.sensor_id AND t4.severity = 2
WHERE t1.sensor = ‘$sensor’
AND t1.line_id = ‘$line_id’
AND $__timeFilter(t1.end_timestamp)

What I found on forums is that this should be possible with Transforms - Config from query. But I cannot find any example how to do this. Can someone help me with this