---
id: post/yzhums-com/61561
type: post
title: "Dynamics 365 Business Central: How to calculate the total (sum) of a column in a table (Four ways)"
summary: "The post explains four methods to calculate column totals in Business Central: using AL loops (for, foreach, while, repeat-until), the Record.CalcSums method, Query objects with aggregation, and FlowFields. Each approach has different use cases and performance characteristics for developers calculating sums of data."
tier: community
language: en
tags:
  - al code
  - loops
  - totals
  - query objects
  - flowfields
  - calcsums
  - aggregation
system: development
review:
  state: reviewed
  by: opus
  at: "2026-10-26T06:42:40.221Z"
  flags: []
generated:
  at: "2026-10-26T05:51:10.938Z"
  pipeline: 0.2.0
  prompts:
    extract-post: 1
  input_hash: 0e364e7adee5161e066ed6fd2fb6683b1bd4287d0d72553630c1647f47a9afac
evidence:
  - kind: blog
    url: https://yzhums.com/61561/
    title: "Dynamics 365 Business Central: How to calculate the total (sum) of a column in a table (Four ways)"
    date: "2025-05-30"
    commit: null
    t: null
    quote: null
  - kind: blog
    url: https://yzhums.com/61561/
    title: "Dynamics 365 Business Central: How to calculate the total (sum) of a column in a table (Four ways)"
    date: "2025-05-30"
    commit: null
    t: null
    quote: The CalcSums function is used to calculate a total for a specific field, based on the filters of the dataset.
  - kind: blog
    url: https://yzhums.com/61561/
    title: "Dynamics 365 Business Central: How to calculate the total (sum) of a column in a table (Four ways)"
    date: "2025-05-30"
    commit: null
    t: null
    quote: This is very useful for displaying totals on a page, as there is no need to add additional logic, just the properties.
  - kind: blog
    url: https://yzhums.com/61561/
    title: "Dynamics 365 Business Central: How to calculate the total (sum) of a column in a table (Four ways)"
    date: "2025-05-30"
    commit: null
    t: null
    quote: If frequent calculations are required, this method is recommended.
links:
  learn: []
  objects:
    - object/table/21
    - object/table/18
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
  related:
    - to: post/yzhums-com/76518
      title: "Business Central 2026 release wave 2 (BC29): AL developers can turn indexes on/off in AL code"
      label: possibly related
      why: both name Table 21 "Cust. Ledger Entry"
      by: code
    - to: post/aardvarklabs-blog/1822
      title: "Business Central Queries: Simplifying Complex Data"
      label: possibly related
      why: both name Table 21 "Cust. Ledger Entry"
      by: code
    - to: post/aardvarklabs-blog/1816
      title: Creating Data Driven Text with AI in Business Central
      label: possibly related
      why: both name Table 21 "Cust. Ledger Entry"
      by: code
    - to: post/yzhums-com/31884
      title: "Dynamics 365 Business Central: Quickly get next Sequence/Entry Number (without using FindLast -> Entry No. + 1)"
      label: possibly related
      why: both name Table 21 "Cust. Ledger Entry"
      by: code
post_id: "61561"
source_id: yzhums-com
source_name: Dynamics 365 Lab - Yun Zhu
url: https://yzhums.com/61561/
published_at: "2025-05-30T01:28:02.000Z"
author: Yun Zhu
full_text: false
words: 1561
quotes:
  - text: The CalcSums function is used to calculate a total for a specific field, based on the filters of the dataset.
    why_it_matters: Explains the core purpose and mechanism of the CalcSums method, the most efficient approach for total calculations
  - text: This is very useful for displaying totals on a page, as there is no need to add additional logic, just the properties.
    why_it_matters: "Highlights the key advantage of FlowFields: automatic calculation without code, reducing development effort"
  - text: If frequent calculations are required, this method is recommended.
    why_it_matters: Identifies when Query objects should be used, guiding developers to choose the right approach for their scenario
code_objects_mentioned:
  - table Cust. Ledger Entry
  - table Customer
  - query CustLedgerEntriesGroupByYear
  - other pageextension CustomerLedgerEntriesExt
  - other pageextension CustomerListExt
  - other tableextension CustomerExt
systems:
  - development
  - platform
versions_mentioned:
  - 2025 wave 1
cautions:
  - kind: warning
    quote: But please note that this method does not support Flowfield.
    objects: []
    events: []
    versions: []
preview:
  embeddable: true
  frame_url: null
  image: https://yzhums.com/wp-content/uploads/2025/05/Snipaste_2025-05-28_14-35-12.png
  image_alt: null
  image_w: null
  image_h: null
  site_name: Dynamics 365 Lab
  favicon: https://yzhums.com/wp-content/uploads/2020/08/cropped-logo-3-32x32.png
  probed_at: "2026-10-26T06:19:53.238Z"
---

# Dynamics 365 Business Central: How to calculate the total (sum) of a column in a table (Four ways)

[Read the post](https://yzhums.com/61561/) · Dynamics 365 Lab - Yun Zhu (Yun Zhu, MVP) · 2025-05-30 · 1561 words · tier community · reviewed (checked by Opus)

> The post explains four methods to calculate column totals in Business Central: using AL loops (for, foreach, while, repeat-until), the Record.CalcSums method, Query objects with aggregation, and FlowFields. Each approach has different use cases and performance characteristics for developers calculating sums of data.

## Key points

- AL loops such as repeat-until work in every situation but are not the most efficient way to total a column
- CalcSums totals a field using current filters, is fastest with matching SumIndexFields keys, and does not accept FlowFields
- Query objects with the Sum method, optionally grouped by Year, are recommended for frequent calculations at the cost of an extra object
- FlowFields defined with CalcFormula show totals on pages without extra code but need a new field in a table

## Quotes

- "The CalcSums function is used to calculate a total for a specific field, based on the filters of the dataset." (Explains the core purpose and mechanism of the CalcSums method, the most efficient approach for total calculations)
- "This is very useful for displaying totals on a page, as there is no need to add additional logic, just the properties." (Highlights the key advantage of FlowFields: automatic calculation without code, reducing development effort)
- "If frequent calculations are required, this method is recommended." (Identifies when Query objects should be used, guiding developers to choose the right approach for their scenario)

## AL objects mentioned

As named in the post. A name that matches one object page by exact type and name links to it; the others stay as named.

- [table 21 "Cust. Ledger Entry"](../../objects/table/21.md)
- [table 18 "Customer"](../../objects/table/18.md)
- query "CustLedgerEntriesGroupByYear"
- other "pageextension CustomerLedgerEntriesExt"
- other "pageextension CustomerListExt"
- other "tableextension CustomerExt"

Not found in BC28-30: query "CustLedgerEntriesGroupByYear".

## Possibly related

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

- [Business Central 2026 release wave 2 (BC29): AL developers can turn indexes on/off in AL code](../../posts/yzhums-com/76518.md) — possibly related: both name Table 21 "Cust. Ledger Entry"
- [Business Central Queries: Simplifying Complex Data](../../posts/aardvarklabs-blog/1822.md) — possibly related: both name Table 21 "Cust. Ledger Entry"
- [Creating Data Driven Text with AI in Business Central](../../posts/aardvarklabs-blog/1816.md) — possibly related: both name Table 21 "Cust. Ledger Entry"
- [Dynamics 365 Business Central: Quickly get next Sequence/Entry Number (without using FindLast -> Entry No. + 1)](../../posts/yzhums-com/31884.md) — possibly related: both name Table 21 "Cust. Ledger Entry"

## Heads up

- warning: "But please note that this method does not support Flowfield."

## Context

- Features: record loops, CalcSums method, Query aggregation, FlowFields, Sum calculations, Date grouping in queries, SumIndexFields
- Versions: 2025 wave 1

Source: Dynamics 365 Lab - Yun Zhu, community blog. Summary, key points and quotes are derived (CONTENT-NOTICE.md); read the original for the full text.
