How to set series names that corresponds to multi-value variable values

I’m using Grafana v9.3.8

I used PostgreSQL query to display separate series on single chart (X axis - build ID, Y axis - average time) for each KPI:

SELECT DISTINCT ON (kpi, build_id)
   kpi as KPI,
   build_id AS BUILD_ID, 
   average_time AS AVERAGE_TIME
   FROM <MY_TABLE> WHERE kpi IN (${kpi}); # $kpi is multi-value variable

I also added Transformation: Partition by values: kpi
The chart is OK but the series labels in Legend displayed as Series 1, Series 2, …
I want to rename series in Legend with values of multi-value variable (number and values are unknown initially and depends on users choice, so cannot set manually)

I tried Standard options: Display name: $kpi, but that didn’t work.
Also tried Overrides: Fields with name: kpi (base field name): Add override property: Display name: ${__series.name}… with no luck