# Filtering values in calculated metric

**URL:** <https://discuss.prometheus.io/t/filtering-values-in-calculated-metric/1612>\
**Category:** PromQL\
**Created:** [April 24, 2023, 7:46am UTC](https://discuss.prometheus.io/t/filtering-values-in-calculated-metric/1612 "2023-04-24T07:46:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![GerrAlexLTD](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.prometheus.io/gerralexltd/32/688_2.png) [@GerrAlexLTD](https://discuss.prometheus.io/u/GerrAlexLTD)\
**Post date:** [April 24, 2023, 7:46am UTC](https://discuss.prometheus.io/t/filtering-values-in-calculated-metric/1612/1 "2023-04-24T07:46:32Z")

</div>

Hello,  
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?
