You can achieve it through Set analysis if you want to do it on the front end.
But I usually try to do all calculations on the back-end for performance reasons. Every calculation that Qlikview performs on the front end eats up memory.
The file attached shows how to do it on the back end.