Thank you for getting back to me. I am not entirely surprised there are questions.
What we are trying to achieve is to create a formatted balance sheet according to the users’ requirements for appearance and method of calculation. This is defined internally in our accounting software and exported to Power BI.
If you look at the table Template - Balance Sheet and make sure it is sorted ascending by sequence number that will give you the idea of what we are doing.
You will see that there are three line types, Header, Data and Calculated.
Data lines are easy as each has an associated account code and that is being achieved in the calculation in lines 6 to 9 in the measure. That simply adds up the records in NlTransactionsPosted with the same account code.
With the calculated line types we are interpreting the the instructions which refer to data lines by sequence number to find its account code and then add those transactions up.
The actual calculation commands are add, sub, div, %, cpy, adr. For the moment we are just working with the add command just to get the principle correct. The others, with the exception of adr (add up a range of lines) will be simple.
In the Measure i have used things like <> to mean not equal to either blank or adr but in fact it makes no difference because if they are removed it does not change things.
If you need anything more please let me know and thank you for taking the trouble.
We are interested in the calculated lines