JMeter mathematical function
Check out the functions page for Jmeter. It has tons of cool math tools that you can plug anywhere in your script. You’ll most likely end up doing a jexl command, which would look something like this: ${__jexl2(${var1}-${var2})}