FR Income Statement in comparison by Segment (Branches)

We have a database for Company A with 10 branches and another database for Company B with 6 branches. 

Both using the same COA with Segment-1 as GL Code and Segment-2 as Branches.

We need an Income Statement to show the comparison of branches in one report for each company.

Currently, I added the formula for each branch in each column one by one. Whenever there is new branch, I will need to add in the formula in a new column manually.

Since the formula is hardcode the branches for Company A, so need to design another report format for company B.

In FR is there any single formula I can use to show all branches in Columns automatically, regardless of how many branches and the report can be share among database?

Above is just an example, in actual fact, we have more Companies and Branches and it is a hassle task to design and maintain so many reports.