Filtering values in calculated metric

We have a problem with sensor, which send to prometheus INT64_MAX, when detected internal error. Usually this status continues about 2-3s, but it’s very bad for statistic calculations.
We have rules with base view as:
- record: power expr: | modbus_power{location="room_x", device="device_1", register_name="b"} + on() modbus_power{location="room_x", device="device_1", register_name="a"} labels: dc: x room: y rack: z name: x_y_z

We want to modify rules to logic:
if modbus_power{} > 35000 then power{} = last not empty value in metric power{}.
Is there solution for this task?