# Create label based on another queries value

**URL:** <https://discuss.prometheus.io/t/create-label-based-on-another-queries-value/3228>\
**Category:** PromQL\
**Created:** [December 27, 2024, 6:21pm UTC](https://discuss.prometheus.io/t/create-label-based-on-another-queries-value/3228 "2024-12-27T18:21:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fue36](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.prometheus.io/fue36/32/1094_2.png) [@fue36](https://discuss.prometheus.io/u/fue36)\
**Post date:** [December 27, 2024, 6:21pm UTC](https://discuss.prometheus.io/t/create-label-based-on-another-queries-value/3228/1 "2024-12-27T18:21:34Z")

</div>

The following Prometheus query `bsnAPIfLoadChannelUtilization{bsnAPIfSlotId="0",job="cisco_wlc_9800",bsnAPName=~"(AP1)"}'`  
generates the following labels and values:

`bsnAPIfLoadChannelUtilization{bsnAPIfSlotId="0", bsnAPName="AP1", instance="192.168.1.1", job="cisco_wlc_9800"} = 96`

This second query ‘`bsnAPIfPhyChannelNumber{bsnAPIfSlotId="0",job="cisco_wlc_9800",bsnAPName=~"(AP1)"}`’ generates the following labels and values:

`bsnAPIfPhyChannelNumber{bsnAPIfSlotId="0", bsnAPName="AP1", instance="192.168.1.1", job="cisco_wlc_9800"} = 6`

How can I take the value of the second query ‘bsnAPIfPhyChannelNumber’ and create a new label to the first query ‘bsnAPIfLoadChannelUtilization’. Desired output:

bsnAPIfLoadChannelUtilization{bsnAPIfSlotId=“0”, bsnAPName=“AP1”, instance=“192.168.1.1”, job=“cisco\_wlc\_9800”, **bsnAPIfPhyChannelNumber=“6”** } = 96

I’ve tried various AI inspired queries using group\_left without success. Ultimately I’m trying to show the channel number next to the AP name in Grafana legend.

Thank you.
