You are correct that buttons with latch behaviour are incompatible with local variables, this is by design.
You don't show your program, so I'm just guessing here. But just use switch when pressed instead. When the measurement is done, set the button back to false using a local variable.
Btw, people will inevitibly come here to tell you that local variables are terrible and you should use a state machine or producer/consumer architecture. I agree, but I'll also say that for simple (non-production) programs or beginner level programs, just use what works, you'll figure out better ways soon enough.