Now accepting guest editorial from SAP, Oracle, Workday and ServiceNow practitioners.Pitch a guide
The Sign-Off Table

Lesson 5 of 6

Custom queries

7 min

When no delivered query fits, a key user can build one with the Custom Analytical Queries app, without programming. The result behaves like any other analytical query: it can be opened as a multidimensional report, found in the Query Browser and, depending on setup, consumed by other SAP analytics tools. This lesson builds a simple one and then covers the governance that keeps custom queries from multiplying.

Good reasons to build one

  • You need a different default layout of rows and columns.
  • You need fixed filters, for example only company code 1710.
  • You need a user-input filter (a prompt) for period or plant.
  • You need a restricted measure, such as revenue for the current year only, next to the total.
  • You need a calculated measure, such as margin percentage or variance between two measures.
  • You need fields from a custom CDS view that a key user created.

Building a query, step by step

  1. CreateIn Custom Analytical Queries, create a new query with a clear name and description
  2. Data sourceChoose a released cube view, such as one for billing document items
  3. FieldsSelect the measures and dimensions you need; leave the rest out
  4. DisplayPlace each field in rows, columns or free; check field settings such as totals
  5. FiltersAdd fixed filters and user-input filters
  6. MeasuresOptionally add restricted and calculated measures
  7. Save and previewSave as a draft and preview with real data
  8. PublishPublish so it can be used by reports, tiles and other tools
Building a custom analytical query.
The Sign-Off Table · thesignofftable.com/academy/sap-xpr-203

Defaults versus restrictions

An analytical query strictly defines which fields and filters exist, but many settings, such as totals and zero suppression, are only defaults: business users can change them at run time. Fixed filters, on the other hand, cannot be removed by the user. Use fixed filters for scope that must never change (the company code of a statutory report) and user-input filters for choices the user should make (the period).

Getting it to production

Key user objects such as custom queries are created in a system and then need to reach production in a controlled way. In SAP S/4HANA Cloud Public Edition this follows the key user transport process of the landscape; in on-premise and Private Edition the key user extensibility objects are recorded and transported with SAP's tooling for key user adaptations. Your project decides whether key users build in a development system and transport, or build directly in production for personal analysis. Either way, treat a shared query like any other change: specify, build, test, approve, transport.

Governance: stop the multiplication

Custom queries are easy to create, which is exactly why they multiply. Without rules, a company ends up with dozens of near-identical "revenue" queries that disagree in small ways, nobody knows which is right, and every upgrade means retesting them all.

Personal usePrivate query or bookmark; no formal review
Team convenienceShared query with an owner and a naming prefix; light review
Important but narrowOwner, documented definition, tested against source documents
GovernedProcess owner sign-off, test cases, transported through the landscape, reviewed after upgrades
Match the governance of a custom query to its reach and impact.
The Sign-Off Table · thesignofftable.com/academy/sap-xpr-203
  • Check the Query Browser for an existing query before creating a new one.
  • Use a naming convention that shows the owner and purpose, such as a "Contoso –" prefix and the process area.
  • Document the definition: data source, filters, restricted and calculated measures.
  • Give every shared query an owner who maintains it and answers questions.
  • Review custom queries periodically and retire unused ones.

What would you do?

Maria wants a query identical to an existing "Contoso – Alternator billing by customer" except with plant as an extra dimension. What should she do?

Key points
  • The Custom Analytical Queries app lets key users build queries on released cube views without code.
  • Steps: data source, fields, display, filters, restricted and calculated measures, save, preview, publish.
  • Fixed filters cannot be removed by users; many layout settings are defaults users can change.
  • Shared custom queries need an owner, a naming convention, a documented definition and a path through the landscape.
  • Extend an existing governed query before creating a near-duplicate.

Check your understanding · not graded

Lesson check

  1. 1. Which app do key users use to build their own analytical queries?

  2. 2. What does a restricted measure do?

  3. 3. What type of view is a custom analytical query usually built on?

  4. 4. Why do custom queries need governance?