My current query is ```select tal.amount, ...
# suiteql
n
My current query is
Copy code
select tal.amount,
          cr.exchangerate,
          tal.transaction,
          t.trandate as date,
          t.exchangerate
   from transactionaccountingline tal
     inner join transaction t on t.id = tal.transaction
     inner join transactionline tl on tl.transaction = tal.transaction and tal.transactionline = tl.id
     inner join subsidiary s on s.id = tl.subsidiary 
     inner join currencyrate cr on cr.effectivedate = t.trandate and cr.transactioncurrency = t.currency
   where t.postingperiod = '<period>'
     and tal.account = '<account id>'
     and t.subsidiary = '<subsidiary id>'
     and cr.basecurrency = '<parent currency>'
b
might want to try BUILTIN.CONSOLIDATE
this is one of those times where you may actually want to create a query object and use Query.createColumn to make your query first
it allows you to use the field context to use currency consolidation
you can later use Query.toSuiteQl if you just wanted the suiteql
n
It’s rather unclear to me how to actually use
BUILTIN.CONSOLIDATE
as the docs don’t describe what the fields are. In this case, would I want something like
Copy code
select BUILTIN.CONSOLIDATE(tal.amount, 'INCOME', '<parent_curr_id>', '<sub_currency_id>', '<sub_id>', '<period_id>', '<book_id>'>)
from transactionaccountingline tal
Also if possible I’d love to be able to consolidate more from first principles rather than use a builtin
b
i would recommend getting a dataset in the ui to get the amount you wanted
then load the dataset to log its suiteql if you really wanted suiteql
n
I haven’t tried workbooks yet, thanks for the pointer!
b
calculating the consolidated exchange rate yourself involves understanding the different consolidated exchange rate types
you are very lucky if you can just use the exchange rate from the transaction, that basically means no consolidation
n
Yea. For this instance I am consolidating a single expense account, so I am using the weighted average of the exchange rate on the day of the transaction (
transaction.trandate
), but as I said I am off by $5
b
there is a table for the consolidated exchange rates that you should be using
🙌 1
n
Oh really??
Is that on a SuiteQL table somewhere?
Found it!
consolidatedexchangerate
OK that was easy, just consolidated the income statement correctly. Thank you!