title: Grafana - InfluxDB 2 - Label/Alias data
body: <p>I am in the processing of migrating my panels from using the SQL syntax (from InfluxDB version 1.X) to the new influx syntax (InfluxDB version 2).</p>
  <p>There is an issue with the labels of the data. It includes the attributes that I used to filter it. For example, if I select data from a range that contains 2 days, it splits the data up. See the screenshot below:</p>
  <p><a href="https://i.stack.imgur.com/dVMLH.png" rel="noreferrer"><img src="https://i.stack.imgur.com/dVMLH.png" alt="enter image description here" /></a></p>
  <p>This completely messes the chart up. The base code looks like this:</p>
  <pre><code>from(bucket: &quot;main&quot;)
    |&gt; range(start: v.timeRangeStart, stop:v.timeRangeStop)
    |&gt; filter(fn: (r) =&gt;
        r._measurement == &quot;POWER&quot; and
        r._field == &quot;value&quot; and
        r.device == &quot;living_room&quot;
    )
    |&gt; aggregateWindow(every: v.windowPeriod, fn: sum)
  </code></pre>
  <p>It should obviously just be &quot;POWER&quot; and &quot;CURRENT&quot;.</p>
  <p>I tried a dozen of different approaches, but cannot come up with a working solution.</p>
  <p>For example, if I do:</p>
  <pre><code>from(bucket: &quot;main&quot;)
    |&gt; range(start: v.timeRangeStart, stop:v.timeRangeStop)
    |&gt; filter(fn: (r) =&gt;
        r._measurement == &quot;POWER&quot; and
        r._field == &quot;value&quot; and
        r.device == &quot;living_room&quot;
    )
    |&gt; aggregateWindow(every: v.windowPeriod, fn: sum)
    |&gt; map(fn: (r) =&gt; ({ POWER: r._value }))
  </code></pre>
  <p>it says &quot;Data does not have a time field&quot;.</p>
  <p>I also tried using</p>
  <pre><code>from(bucket: &quot;main&quot;)
    |&gt; range(start: v.timeRangeStart, stop:v.timeRangeStop)
    |&gt; filter(fn: (r) =&gt;
        r._measurement == &quot;POWER&quot; and
        r._field == &quot;value&quot; and
        r.device == &quot;living_room&quot;
    )
    |&gt; aggregateWindow(every: v.windowPeriod, fn: sum)
    |&gt; yield(name: &quot;POWER&quot;)
  </code></pre>
  <p>that does not work either. I tried many other things without success.</p>
  <p>How can I fix this?</p>