"grouping the "bcm modecommands" by maximum vehicle speed " using flux query and represent in Bar Graph

from(bucket: “Grafana_Bucket”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r._measurement == “MAY_4_New _Regen_Switch_logic_V24_fixed_portable”)
|> filter(fn: (r) => r._field == “Vehicle_Speed” or r._field == “BCM_ModeCommand”)
|> group(columns: [“BCM_ModeCommand”])
|> max(column: “_value_Vehicle_Speed”)
|> yield(name: “max_speed”)
i have to calculate maximum of vehiclespeed and this should be grouped by BcmModecommands…i have to represent this in Graph. but by executing this query grtting error:invalid: Error creating group plans for namespace ‘b7ee3863cd636746_adb3c8fabd734ddc’: Error during planning: Group column ‘BCM_ModeCommand’ not found in tag columns: [“dummy”] please help me to resolve this

Hi,

Check whether that tag column exists in your measurement or not. If it exists, then keep the group function after maxfunction and try again

Hi Great Response. @AVVS_Sudheer
I tried your solution but still getting error"invalid: runtime error @5:6-5:34: max: no column “Vehicle_Speed” exists but i have this vehicle_speed in infludb data base

Hi,

Check the spelling and which are capital and small letters for “Vehicle_Speed” and run the query again.

Hi @AVVS_Sudheer checked many times.every field has correct spelt
Can you
image
please help me with this.i have to plot graph like this.

Hi,

If every tag exists in the ,measurement, just save that report and close it. clean the browser and open the report again and refresh. Check if it works.

@AVVS_Sudheer Tag does not exists in the measurement. How to do it now?I am not getting idea

Hi,

If tag doesn’t exist in the measurement, then ask your database team to create a new tag “Vehicle_Speed” in the measurement and try.

@AVVS_Sudheer I have vehicle_speed tag but i dont have BCM_modecommands such as sonic,ride,eco and range.(In BCM_modecommand Tag I have values like 0,1,2 and 3) any idea how to plot this values into above grapgh

Hi,

You can use if else as below

If value=1 then “Sonic”
else if value=2 then “Ride”
else if value=3 then “Dash”
else “Eco”

Here values 1,2,3 are from your bucket. I tried now it is working fine.

@AVVS_Sudheer I tried your solution
from(bucket: “Grafana_Bucket”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r._measurement == “MAY_4_New _Regen_Switch_logic_V24_fixed_portable”)
|> filter(fn: (r) => r._field == “Vehicle_Speed” or r._field == “BCM_ModeCommand”)
|> max(column: “Vehicle_Speed”)
|> map(fn: (r) => ({
r with
_field: if r._field == “BCM_ModeCommand” then
if r._value == 1.0 then “Sonic”
else if r._value == 2.0 then “Ride”
else if r._value == 3.0 then “Dash”
else “Eco”
else r._field
}))
|> group(columns: [“_field”])
|> yield(name: “max_speed”)
while executing this query i am getting error:invalid: runtime error @5:6-5:34: max: no column “Vehicle_Speed” exists But vehicle_Speed already exist