Rename Tags in Influx code


I can rename one tag, but I have a table as below



I can rename one tag by using the code

|> rename(columns:{_value:“AP”})
Original tag is ap2012 and I have renamed as AP, like that I have some tags like KA2012,MP2013, MH2022 which must be renamed as KA,MP, MH etc

How to rename the above tags and it must be displayed in tabular format as shown above

Hello @AVVS_Sudheer,
Unfortunately you’ll have to rename them like you renamed the other one.
If I’m understanding you correctly.
It would be helpful if you could show your input table as well as your expected output (thanks for sharing).

It’s possible you’re asking for a pivot?


My input table is

Date _value Country State
|01-05-2023| 10 India |AP2012|
|01-05-2023| 20 India |KA2012|
|01-05-2023| 30 India |MP2013|

I want the output tabe as below

Date _value Country Tag
|01-05-2023| 10 |India |AP|
|01-05-2023| 20 |India |KA|
|01-05-2023| 30 |India |MP|

It is not pivot. It is normal table format, what I want. If it is pivot, it will be displayed as below
01-05-2023 India 01 20 25 30
01-05-2023 India 10 20 30 40
01-05-2023 India 30 10 20 50


I got the solution in normal table format only. I have used the query as below

from(bucket: “Sample”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “bucket1”)
|> filter(fn: (r)=> r[“tag1”] == “AP” or r[“tag1”] == “KA” or r[“tag1”] == “MP”) — Here we have to place the tags with or operator
|> filter(fn: (r) => r[“country”] == “India”)
|> group(columns:)
|> drop(columns:[“_start”, “_stop”, “_measurement”, “_field”,“tag”])

Here tags are constant and we may have 10 or 12 tags