title: influxDB: How to convert field to tag in influxDB v2.0
body: <p>We need to convert field to tag in influxDB v2.0 but not able to find any proper solution.
  Can someone help me out to achieve the same ?</p>
  <p>Solution we found was to create new measurement by altering fields and tags of existing measurement but not able achieve it using Flux language.</p>
  <p>Using below flux query we can copy the data from one measurement to another but not able to change the field to tag while adding data in new measurement.</p>
  <pre><code>from(bucket: &quot;bucket_name&quot;)
      |&gt; range(start: -10y)
      |&gt; filter(fn: (r) =&gt; r._measurement == &quot;cu_om&quot;)
      |&gt; aggregateWindow(every: 5s, fn: last, createEmpty: false)
      |&gt; yield(name: &quot;last&quot;)
      |&gt; set(key: &quot;_measurement&quot;, value: &quot;cu_om_new1&quot;)
      |&gt; to(org: &quot;org_name&quot;, bucket: &quot;bucket_name&quot;)
  </code></pre>
  <p>Any help appreciated.</p>