---
id: change/bcapps/13262
type: change
title: "#13262 [Financial Reports] Trial Balance by Period (Excel) should use a query-based approach rather than loop and CalcFields"
summary: Trial Balance by Period (Excel) (report 4408) now gets amounts from a new query, EXR Trial Bal by Period, grouped by global dimensions instead of looping with CalcFields. This cuts SQL calls to two per account and period, no matter how many dimension values exist, while producing the same dataset rows.
tier: official
language: en
tags:
  - performance
  - main
  - bc30
  - query exr trial bal by period
  - report exr trial bal by period excel
  - permissionset excel reports - objects
system: finance
review:
  state: reviewed
  by: opus
  at: "2026-10-28T10:56:17.829Z"
  flags: []
generated:
  at: "2026-11-17T00:16:35.786Z"
  pipeline: 0.2.0
  prompts:
    extract-change: 1
  input_hash: a1af339d809df26ed0c499da8c3918ac9a11b099
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/pull/13262
    title: "microsoft/BCApps#13262: [Financial Reports] Trial Balance by Period (Excel) should use a query-based approach rather than loop and CalcFields"
    date: "2026-10-27"
    commit: a1af339d809df26ed0c499da8c3918ac9a11b099
    t: null
    quote: null
links:
  learn: []
  objects:
    - object/query/4408
    - object/report/4408
    - object/permissionset/4401
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
  changes: []
  related:
    - to: https://learn.microsoft.com/dynamics365/business-central/reports/report-38
      title: Trial Balance by Period (Report)
      label: possibly related
      why: Documents Trial Balance by Period report that this change optimizes with query-based approach.
      by: model
number: 13262
repo: microsoft/BCApps
source_id: bcapps-prs
url: https://github.com/microsoft/BCApps/pull/13262
kind: pr
base_branch: main
major: "30"
merged_at: "2026-10-27T15:55:17Z"
author: dcenic
author_type: User
community_contribution: false
labels:
  - "AL: Apps (W1)"
  - "Team: Finance"
change_class: code
change_kind: performance
behavior_change: false
breaking: false
files:
  count: 4
  additions: 408
  deletions: 38
  al: 3
apps:
  - ExcelReports
objects_touched:
  - key: query/4408
    page: query/4408
    type: query
    id: 4408
    name: EXR Trial Bal by Period
    app: ExcelReports
    status: added
  - key: report/4408
    page: report/4408
    type: report
    id: 4408
    name: EXR Trial Bal by Period Excel
    app: ExcelReports
    status: modified
  - key: permissionset/4401
    page: permissionset/4401
    type: permissionset
    id: 4401
    name: Excel Reports - Objects
    app: ExcelReports
    status: modified
objects_unjoined: []
obsoletions: []
backports:
  - number: 13316
    base: releases/29.x
    url: https://github.com/microsoft/BCApps/pull/13316
fixes_issues: []
work_items:
  - 656773
systems:
  - finance
  - reporting
quote: null
joined_against:
  major: "30"
  commit: d2abc1d2ceae394331716c8183ef60e1534c2ce0
---

# #13262 [Financial Reports] Trial Balance by Period (Excel) should use a query-based approach rather than loop and CalcFields

> Trial Balance by Period (Excel) (report 4408) now gets amounts from a new query, EXR Trial Bal by Period, grouped by global dimensions instead of looping with CalcFields. This cuts SQL calls to two per account and period, no matter how many dimension values exist, while producing the same dataset rows.

[Pull request](https://github.com/microsoft/BCApps/pull/13262) · merged into `main` (BC30) on 2026-10-27 by dcenic · 4 files (+408 -38), 3 AL · performance · tier official · reviewed (checked by Opus)

## What changed

- Replaced inefficient loop-and-CalcFields pattern with a single query that groups G/L entries by dimension values
- Reduces SQL calls from approximately 4 × accounts × periods × (1 + D1 + D2 + D1·D2) to just 2 × accounts × periods
- Query runs twice per account per period: once for net change and once for balance
- Dimension values loaded once in OnPreReport instead of repeatedly queried
- Dataset generation moved from database to memory buffer, maintaining same output format with and without zero-value filtering

## AL objects touched

- [Query 4408 "EXR Trial Bal by Period"](../../objects/query/4408.md), ExcelReports: added
- [Report 4408 "EXR Trial Bal by Period Excel"](../../objects/report/4408.md), ExcelReports: modified
- [Permission set 4401 "Excel Reports - Objects"](../../objects/permissionset/4401.md), ExcelReports: modified

## Also merged into

- [#13316](https://github.com/microsoft/BCApps/pull/13316) into `releases/29.x` on 2026-10-28

## Context

- Work items: AB#656773
- Labels: AL: Apps (W1), Team: Finance
- Systems: finance, reporting

## Possibly related

No source states these links: they share an object, a model read them, or a person found the same subject.

- [Trial Balance by Period (Report)](https://learn.microsoft.com/dynamics365/business-central/reports/report-38) — possibly related: Documents Trial Balance by Period report that this change optimizes with query-based approach. (model-linked)

Source: metadata of a merged pull request in microsoft/BCApps (bcapps): title, labels, changed paths and counts, with a summary in our words. No source text and no description beyond one short quote (D10, D61).
