Based on the data given by you, I have just done a rough work in attached excel sheet.
Not clear on what you mean by service period in particular branch. if you have the joining date for a branch, you can use the same formula i.e. =datedif()
Hope this is help for your learning.
From Saudi Arabia, Riyadh
If you are knowledgeable about any fact, resource or experience related to this topic - please add your views.