I think we're going to need more information to answer this accurately. Namely, when you say 'Balance of all accounts', does that include retirement accounts and more importantly, did you receive any distributions from those accounts? If so were they pre-tax or post-tax retirement accounts?
The problem with using account balances, is that if those balances include brokerage accounts, taking the value increase from 2017 gives you both your contributions, dividends and change in value which is probably not what you want for calculating expenses for 2017. Rather I'd just use SAVINGS_CONTRIBUTIONS_2017 and include only interest income in your INCOME on non-retirement accounts.
Then:
EXPENSES = INCOME - SAVINGS_CONTRIBUTIONS_2017 - TAXES.
This also assumes you're lumping sales tax into EXPENSES rather than TAXES - few people separately track sales tax as it's an accounting nightmare.
Another reason to leave out retirement accounts is that you could easily argue that any loss in those is an expense, thus would you include that? I wouldn't, at least not until I withdraw it and the gain/loss becomes realized.
Finally, calculating SAVINGS_CONTRIBUTIONS is generally pretty easy (e.g. max 401k = 18000 + max IRA ($5500), etc).