In settings → Chart of accounts you can add groups and totals to the the Profit and Loss Statement using these buttons:
Then you can sort the accounts and groups using the double headed up-down arrow to get the report to be displayed as shown by this extract from lower part of my P&L statement