Given an operator $\hat{Q}(x)$, the expectation value of the observable $\langle Q \rangle$ is calculated by integrating the probability distribution over the entire space as
\begin{equation} \langle Q \rangle = \int_{-\infty}^{\infty} \psi^{*}(x) \hat{Q}(x) \psi(x) dx \end{equation}
Is it possible to calculate the expectation value $\langle Q \rangle_{ab}$ over just a finite range $x \in [a,b]$ such that
\begin{equation} \langle Q \rangle_{ab} = \int_{a}^{b} \psi^{*}(x) \hat{Q}(x) \psi(x) dx. \end{equation}
It would seem that the answer is yes. For example, a detector in the lab usually takes measurements only in a finite space rather than over an infinite space. Furthermore, as as example, it seems that for a piece-wise potential that gives three separate wave functions $\psi_{1}(x), \psi_{2}(x) \text{ and } \psi_{3}(x)$, the above calculation would be performed due to
\begin{equation} \langle Q \rangle = \int_{-\infty}^{a} \psi_{1}^{*}(x) \hat{Q}(x) \psi_{1}(x) dx + \int_{a}^{b} \psi_{2}^{*}(x) \hat{Q}(x) \psi_{2}(x) dx + \int_{b}^{\infty} \psi_{3}^{*}(x) \hat{Q}(x) \psi_{3}(x) dx. \end{equation}