Howe to filter the records by another filed's value?

I want to get the fields by another filed’s value. such like " SELECT DW1COntrolStatus,DW2ControlStatus Where Waste=false". The below code is not right. How to write the code?

from(bucket: "scada")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "PMD43")
  |> filter(fn: (r) => (r["_field"] == "Waste" and r._value==false) or r["_field"] == "DW1ControlStatus"  or r["_field"] == "DW2ControlStatus" )
  |> aggregateWindow(every: 5m, fn: last, createEmpty: false)

Hi @welkin,
Welcome to the community! You could try the following:

from(bucket: "scada")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "PMD43")
  |> filter(fn: (r) => (r["_field"] == "Waste") or r["_field"] == "DW1ControlStatus"  or r["_field"] == "DW2ControlStatus" )
  |> aggregateWindow(every: 5m, fn: last, createEmpty: false)
|> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value")  
|> filter(fn: (r) => r.Waste == false)   


@Jay_Clifford ,Thanks for your reply! The fileds’ name is changed automaticly.How to change it? And it can’t refresh in Grafana.
How to hide the column of Waste in the result?