ERPClimb logoERPClimb
BW Queries
BW / Analyticsintermediate 7 min read

Query Design Elements: Restricted/Calculated Key Figures, Variables, Conditions, and Exceptions (Part 2)

Preview · a free account unlocks the full lesson

Key takeaway

Learn how to build advanced query logic using restricted and calculated key figures, variable types, conditions, and exceptions, and how these choices affect performance and front-end consumption.

In this lessonShow sections

Visual overview

Query Design Elements: Restricted/Calculated Key Figures, Variables, Conditions, and Exceptions (Part 2) — learning sheetIn one line: Learn how to build advanced query logic using restricted and calculated key figures, variable types, conditions, and exceptions, and how these choices affect performance and front-end consumption.ERPClimb.com / BW / LESSON 2/4 / LEARNING SHEETQuery Design Elements: Restricted/Calculated Key Figures,Variables, Conditions, and Exceptions (Part 2)1 · IN ONE LINELearn how to build advanced query logic using restricted and calculated key figures,variable types, conditions, and exceptions, and how these choices affect performance andfront-end consumption.2 · KEY IDEAS EXPLAINED1Once basic query structure is understood, mostreal-world reporting requirements need query-levelcalculations and conditional logic that go beyondsimple rows and columns. Restricted Key Figures(RKFs) take an existing key figure and apply afixed or variable restriction to one or more…2Variables extend beyond simple characteristicvalue prompts. Common variable types include:characteristic value variables (user enters ordefaults a value, e.g., fiscal year), textvariables (dynamically change a column header,e.g., showing the selected month name), formula…3Conditions filter the result set based on keyfigure values, such as showing only customers withrevenue above a threshold or the top N materialsby quantity. Conditions are evaluated after theOLAP engine calculates the result set, so theyaffect what is displayed but not necessarily what…4From a performance perspective, complex nestedCKFs, especially formulas dividing by key figuresthat can be zero, or heavy use of exceptionaggregation, can slow query runtime and requirecareful testing with realistic data volumes. RKFsrestricted on many characteristics can also…3 · DO · AVOIDBest practice!Common mistakePrefer global restricted/calculated keyfigures when the same KPI logic (e.g., margin…Always guard calculated key figures againstdivision by zero or missing key figures to…Choose variable processing type based on howthe query will be consumed: manual input for…✕Confusing conditions (which filter displayedrows) with exceptions (which only apply…✕Building calculated key figures that divide bya key figure without handling zero or missing…✕Overusing customer-exit variables for logicthat could be handled with simpler replacement…4 · IN A REAL PROJECTA manufacturing client needs a profitability query showing margin percentage by product line, with onlyproduct lines below a 10% margin flagged visually, and only the top 20 customers by revenue displayed toreduce noise for executive reporting. The consultant creates a calculated key figure for margin percentage…Original ERPClimb learning sheet • Verify against your SAP release and edition

Explanation

Once basic query structure is understood, most real-world reporting requirements need query-level calculations and conditional logic that go beyond simple rows and columns. Restricted Key Figures (RKFs) take an existing key figure and apply a fixed or variable restriction to one or more characteristics, producing a new reusable column such as 'Revenue - Current Year' or 'Quantity - Region North'.

Calculated Key Figures (CKFs) combine existing key figures (including RKFs) using formulas, such as computing a margin percentage from revenue and cost key figures. Both RKFs and CKFs can be defined locally within a single query or saved globally for reuse across multiple queries against the same InfoProvider, which is an important design decision: global reuse reduces duplication but increases the blast radius if the definition changes.

Variables extend beyond simple characteristic value prompts. Common variable types include: characteristic value variables (user enters or defaults a value, e.g., fiscal year), text variables (dynamically change a column header, e.g., showing the selected month name), formula variables (inject a value into a calculation, e.g., an exchange rate), and hierarchy node variables (restrict to a selected node in a characteristic hierarchy).

Variables can be manual input, default values, replacement path (deriving the value from another query or characteristic), or customer-exit (ABAP-based logic for complex derivation, common for 'current fiscal period' logic). Processing type selection matters: manual-input variables require user interaction at runtime, while customer-exit variables run automatically, which is important for scheduled/broadcast queries where no user is present to respond to a prompt.

Free account

Create a free account to keep reading

You have read the opening of this lesson. A free ERPClimb account unlocks the rest of it, every other lesson and topic, and your learning history, so you can pick up exactly where you stopped. No card needed.

  • Full explanation
  • Real project scenario
  • Common mistakes
  • Best practices
  • Interview angle

One tap with Google works too. Every topic keeps its first lesson open to everyone.

Keep exploring

Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.