Sub topic 9
Creating queries and KPIs as a key user
A key user is a power user in a business department. Key users adapt analytics in the browser and don't write ABAP. This chapter assumes you know the cube, dimension and query view structure from the earlier chapters, and that you can open apps in the SAP Fiori launchpad. App names and catalog assignments differ between releases, so check your system's app finder for the exact titles.
What key users can and cannot do
Developers build the Virtual Data Model: cubes, dimensions and released queries. Key users build on top of it. They pick an existing cube or query as a data source and shape a new view of it. They cannot change the underlying CDS views, and they cannot see data the cube's access control hides from them.
| Task | Typical app | Result |
|---|---|---|
| Find a suitable cube or query and inspect its fields | View Browser | Knowledge of available measures and dimensions |
| Define rows, columns, filters and calculated measures | Custom Analytical Queries | A new query view in the customer namespace |
| Turn a query measure into a tracked indicator | Manage KPIs and Reports (KPI modeler) | A KPI with target, thresholds and a tile |
The workflow
Step 1: Find a data source
Open the View Browser and search for views by name or label. Look for a view whose data category is cube, because cubes carry the measures and the links to dimensions. Check the field list. A measure you need must be present, and the dimensions you want to group by must be reachable through the cube's associations.
Step 2: Build the custom query
In Custom Analytical Queries, create a query and select the cube as its data source. Then you:
- Place dimension fields on rows, such as customer or country.
- Place measures on columns, such as net amount.
- Add filters, either fixed or as user-entered parameters.
- Add calculated measures, for example a margin percentage.
- Add restricted measures, for example net amount for one sales organization only.
When you publish, the system generates a CDS query view from your definition. It plays the same role as the developer-built ZC_NetAmountByCustomer from earlier chapters, with rows, columns and aggregation, but the key user defined it through a UI.
Step 3: Create the KPI
A KPI (key performance indicator) is a single measure compared against a goal. In the KPI modeler you choose your published query as the data source and select one measure. You then set:
- A filter or dimension scope, for example the current year.
- A target value.
- Thresholds for warning and critical states.
- Whether a higher or lower value is better.
The system evaluates the measure and colors the tile by comparing the result with the thresholds.
Authorizations still apply
A custom query reads through the cube, so the cube's CDS access control applies to every user of the query. A key user who publishes a query to a wide audience does not widen anyone's access. Two users opening the same tile can see different numbers if their authorizations differ. Keep this in mind when a colleague says "my tile shows a different total than yours".
Common errors
- Cube not listed. The view is not a cube or is not released for use in custom queries. Ask the developer to check the data category and release status.
- A measure shows unexpected totals. A calculated measure that divides two sums can be wrong when the system aggregates after the division. Check the calculation's aggregation settings and compare with the cube's default aggregation.
- Mixed currencies or units. Summing amounts without a currency on the column produces incorrect totals or an error. Keep the currency field in the query so the system can convert or separate values.
- KPI shows no data. The KPI filter excludes everything, or your own authorization hides the rows. Test the query directly before blaming the KPI.
- Query changes break a KPI. Removing a measure from a published query breaks KPIs built on it. Create a new version instead.
Exercise
A key user publishes a custom query on a sales cube and builds a KPI tile on it. A colleague with narrower sales organization authorizations opens the tile and sees a smaller value. Is this a defect, and why?
Show answer
It is expected behavior. The custom query reads through the cube, so the cube's CDS access control filters rows per user. The colleague's lower value reflects only the data they are authorized to see. The key user's query definition does not change anyone's authorizations.
Exercise
You need a KPI for "overdue receivables" that turns red when it rises. Which setting must you choose carefully when defining the thresholds?
Show answer
The improvement direction. For overdue receivables a lower value is better, so the KPI must be set so that higher values move toward the warning and critical states. Otherwise the tile colors are reversed.