Pivot field with hyphen

I am trying to pivot data, and one of the tag/values for a column has a hyphen in it (PNL-A). I want to rename the column to a valid value (sans hyphen), but have been unable to escape it.

What is the best way to deal with this situation?

@Patrick808 The hyphen shouldn’t matter. Is it causing an error?

Yes, it is causing an error. My code after the pivot:

|> map(fn: (r) => ({r with _value: r._AC1 + r.AC2 + r.AC3 + r.PNL-Kitchen + r.PNL-Lauandry - r.TeslaWC }))

The error:

error @6:69-6:76: undefined identifier Kitchen

The dot notation is syntactic sugar and it doesn’t work for all column names due to syntax ambiguity. In your case the hypen is seen as a minus sign. Try using r["PNL-Kitchen"] instead.

@Patrick808 :point_up: This. Because of the hyphens in your column names, you need to use bracket notation instead of dot notation. More info here: Flux syntax basics | Flux 0.x Documentation.

1 Like