Deploy Analysis Views in Business Central via AL Code
If you’ve ever configured Analysis Views manually in Business Central and then had to redo it all in a new environment, you know the pain. This post shows you how to define them directly in AL code so they ship with your extension — no manual setup, no repetition.
What Are Analysis Views?
Analysis Views are the built-in pivot grids on Business Central list pages like Item Ledger Entries. They let users group, pivot, filter, and aggregate data on the spot — no Power BI, no Excel export. The catch: by default they’re configured through the UI, so they live only in that environment and can’t be version-controlled.
The AL Approach
AL supports an analysisviews section inside page extensions. Each view points to a JSON definition file bundled with your app that describes columns, groupings, pivot columns, filters, and aggregations. The result:
- Views are version-controlled alongside your code
- They deploy automatically when the extension installs
- Every environment gets the exact same setup
pageextension 50100 ILEExt extends "Item Ledger Entries"
{
analysisviews
{
addlast
{
analysisview(ItemVelocity)
{
DefinitionFile = 'json/ItemVelocity.analysis.json';
Caption = 'Item Velocity';
Visible = true;
}
// ... more views
}
}
}
Each JSON file controls which columns are visible, which become row groups, which pivot, and what aggregation to apply (sum, count, etc.).
The 5 Views in This Project
All five views target the Item Ledger Entries page (Page 38):
- Item Velocity — outbound quantity pivoted by month, grouped by item. Instantly shows which items move fastest.
- Lot Traceability — lot number × item × source type pivot. Ideal for quality and compliance tracking.
- Revenue by Item & Customer Posting Group — sales amount and cost grouped by item and customer segment, filtered to customer entries only. Uses a table join to pull the Customer Posting Group from the Customer table.
- Monthly Trends — posting date grouped by month with quantity, sales, and cost totals. A clean trend overview.
- Item Profitability by Customer Group — sales vs cost per item pivoted by Global Dimension 2, filtered to sale entries. Useful for margin analysis by region or division.
Key Takeaway
You can export any Analysis View you’ve built in the UI, save it as a JSON file, commit it to source control, and ship it as part of your extension. It’s a small workflow change with a big payoff — especially for ISVs or partners deploying to multiple customers.
Watch the full walkthrough on YouTube:
How to Create Analysis Views in Business Central Using AL Code
One Response