My current Query looks like this:
tab5 = from(bucket: “zone/autogen”)
|> range(start: 2021-01-01T00:00:00Z)
|> filter(fn: (r) =>
r._measurement == “M1” and
r.short == “Machine1.ID”
)
|> pivot(
rowKey:["_time"],
columnKey: [“short”,"_field"],
valueColumn: “_value”
)
|>rename(columns: {“Machine1.ID_value_str”:“Mach1”})
|> map(fn: (r) => ({
_time: r._time,
ID: string(v: r.Mach1),
}))
tab6 = from(bucket: “zone/autogen”)
|> range(start: 2021-01-01T00:00:00Z)
|> filter(fn: (r) =>
r._measurement == “M1” and
r.short == “Machine2.ID”
)
|> pivot(
rowKey:["_time"],
columnKey: [“short”,"_field"],
valueColumn: “_value”
)
|>rename(columns: {“Machine2.ID_value_str”:“Mach2”})
|> map(fn: (r) => ({
_time: r._time,
ID: string(v: r.Mach2),
}))
tab7 = from(bucket: “zone/autogen”)
|> range(start: 2021-01-01T00:00:00Z)
|> filter(fn: (r) =>
r._measurement == “M1” and
r.short == “Machine3.ID”
)
|> pivot(
rowKey:["_time"],
columnKey: [“short”,"_field"],
valueColumn: “_value”
)
|>rename(columns: {“Machine3.ID_value_str”:“Mach3”})
|> map(fn: (r) => ({
_time: r._time,
ID: string(v: r.Mach3),
}))
tab8 = from(bucket: “zone/autogen”)
|> range(start: 2021-01-01T00:00:00Z)
|> filter(fn: (r) =>
r._measurement == “M1” and
r.short == “Machine4.ID”
)
|> pivot(
rowKey:["_time"],
columnKey: [“short”,"_field"],
valueColumn: “_value”
)
|>rename(columns: {“Machine4.ID_value_str”:“Mach4”})
|> map(fn: (r) => ({
_time: r._time,
ID: string(v: r.Mach4),
}))
tab9=union(
tables: [tab5,tab6,tab7,tab8]
)