@Tino The from() function returns a different data structure than SQL-like languages. Fields are returned in two separate columns:
_field: Stores the field key
_value: Stores the field value
Also, by default, data is grouped by field, so you’ll have a separate table per field. So the structure of your data when queried looks something like this:
_time
_measurement
_field
_value
2024-05-29T00:00:00Z
myMeasurement
etoday
1
2024-05-29T00:01:00Z
myMeasurement
etoday
1
_time
_measurement
_field
_value
2024-05-29T00:00:00Z
myMeasurement
htotal
1
2024-05-29T00:01:00Z
myMeasurement
htotal
1
_time
_measurement
_field
_value
2024-05-29T00:00:00Z
myMeasurement
powact
1
2024-05-29T00:01:00Z
myMeasurement
powact
1
_time
_measurement
_field
_value
2024-05-29T00:00:00Z
myMeasurement
string1
1
2024-05-29T00:01:00Z
myMeasurement
string1
1
_time
_measurement
_field
_value
2024-05-29T00:00:00Z
myMeasurement
string2
1
2024-05-29T00:01:00Z
myMeasurement
string2
1
_time
_measurement
_field
_value
2024-05-29T00:00:00Z
myMeasurement
wbcharge
1
2024-05-29T00:01:00Z
myMeasurement
wbcharge
1
To perform the operation you’re trying to perform, you need to pivot your fields into columns using the pivot function:
thank you much, this (of course) works like a charm!
But now my graph only shows the value of the new value of etoday…
How do I get the other, original values into the graph?
If you can give me a hint to the right location in the docs I’d be more than happy to try to find a solution by myself. There are examples for doing math operations on data, and there are examples for displaying data – but I can’t find the connection.
Obviously it’s not easy to get a start with this.
@Tino The reason I ask is because InfluxDB dashboards and Grafana give you different control over how data is visualized based on the structure of the query results. InfluxDB dashboards expect “unpivoted” data where the field key is stored in the _field column and the field value is stored in the _value column. In the original solution above, we pivoted the data to perform math on the etoday field. For this to be graphed how you want in an InfluxDB dashboard, you have to make sure the query results are unpivoted. There are a few ways to do this:
Use experimental.unpivot() to restructure your pivoted data