Hi,
How do i merge two rows by time in the same table? I tried join, pivot and union but i can’t get it to work and i would appreciate some help.
Problem:
Flux Query:
Hi,
How do i merge two rows by time in the same table? I tried join, pivot and union but i can’t get it to work and i would appreciate some help.
Problem:
Flux Query:
Hmmm. Everything looks like it should work. Does it just produce a wrong looking table or give you an error? What about the same query in Influx Data Explorer (sometimes Grafana executes Flux queries slightly differently).
Just for kicks, does changing your pivot function like this change anything?
|> pivot(rowKey:["_time"], columnKey: ["device_name"], valueColumn: "_value")
No errors, just wrong looking table unfortunetly.
Influx Data Explorer produces the same table.
Might it have something to do with the different _measurement sources?
|> pivot(rowKey:[“_time”], columnKey: [“device_name”], valueColumn: “_value”)
Separates everything into its own lines instead of merging them.
I’m using this with geomaper and i want them on the same row because i want the tooltip to display coordinates along with the rssi info.
Right now with this table i only get the coordinates in the tooltip.
Yes, it may. Can you try this?
|> pivot(rowKey:["_time"], columnKey: ["_measurement"], valueColumn: "_value")
Yes, this splits it into 3 rows instad of merging them.
Could you switch over to Influx Data Explorer and show the above table (as well as the original one from your first post) with the headings and the table (0, 1, 2, etc.), and to show which columns are in the the same group key?
Yes.
Org:
“Above table”
Is the above from Influx Data Explorer? I was expecting to see column headings like this:
which can be viewed by toggling the View Raw Data toggle:
Sorry, let me do that again. Unfortfunetly i can’t sort them by time side by side.
Org:
and the “above table” seems to be identical?
OK, I think we are getting close.
Can you remove the group()
function from your original query, insert a |> yield(name: "test")
, and post the Influx Data Explorer output here?
Yes, that splits the sources into two tables.
Can you swap the last two functions in your original query and post here?
|> group()
|> pivot(rowKey:["_time..
original query:
Hmm, in Grafana table view it shows correct when swapped.
However in Influx Data Explorer it separates the two into tables.
I guess it working then
Thanks!
OK, awesome. FYI, this article helped me: How to Pivot Your Data in Flux: Working with Columnar Data | InfluxData
I watched that clip 10 times, however i’m quite new to databases.