Before you Begin
Learn how to create calculated, level-based, and share measures in the logical layer of a semantic model in Oracle Analytics Cloud.
Background
This tutorial describes how to build governed semantic models using the Semantic Modeler.
This is the next tutorial in the Create a Semantic Model series. Do the tutorials in the order listed:
- Create the Physical Database, Physical Tables, and Physical Joins
- Create the Business Model, Logical Tables, and Logical Joins
- Create the Subject Areas and Presentation Tables
- Test, Deploy, and Validate a Semantic Model
- Examine Semantic Model Markup Language (SMML) and Integrate Semantic Model With a Git Repository
- Manage Logical Table Sources
- Create Logical Hierarchies
- Create Calculated, Level-Based, and Share Measures
- Create Ragged and Skipped Level Hierarchies
- Create Parent-Child Hierarchies
- Create Aggregate Tables
- Create Time Series Measures
- Create Initialization Blocks and Variables
What Do You Need?
- Access to Oracle Analytics Cloud
- Access to DV Content Author, BI Data Model Author, or a BI Service Administrator role
- Access to the Sample Sales Semantic Model
Create Calculated Measures
In this section, you create a calculated measure in the logical layer's F1 Revenue table using a logical expression and a calculated measure using a function.
Begin with step 3 if you're continuing this tutorial directly after completing the steps in the Create Logical Dimensions tutorial.
- If you closed your semantic model, sign in to Oracle Analytics Cloud using one of DV Content Author, BI Data Model Author or service administrator credentials. On the Home page, click the Navigator , and then click Semantic Models.
- In the Semantic Models page, select Sample Sales, click Actions menu , and then select Open.
- In the Sample Sales semantic model, click the Logical Layer .
- Expand Sample Sales BM, expand F1 Revenue, and select Revenue, and then click Detail View .
- In F1 Revenue Columns, click Add Column .
- In Name, enter
Actual Unit Price
. Click Logical Expression, and then click Open Expression Editor . - In the Expression Editor, click Logical Layer , expand F1 Revenue, and then drag Revenue to the expression field.
- From Operators, double-click the divisor (/). After the divisor, start typing
Uni
, and then selectUnits
. Click Validate, and then click Save in the calculated measure.Actual Unit Price equals Revenue divided by Units.
- In F1 Revenue, click Add Column . In Name, enter
Revenue Rank
. Click Logical Expression, and then click Open Expression Editor . Under Functions, expand Display, and then double-click Rank. - Click Logical Layer , expand F1 Revenue, and then drag Revenue to column in the parentheses next to Rank in the Expression Editor field. Click Validate, and then click Save to save the calculation.
The Revenue Rank columns uses the Rank function for its calculated measure.
- Click Save .
Create Level-Based Measures
In this section, you create measure columns in the Revenue table using physical expressions.
- In the Logical Layer, double-click F1 Revenue. In the Columns tab, click Add Column . Double-click New Column_1 to open the detail view.
- In Name, enter
Product Total Revenue
. - In Sources with Physical Expression selected, click Add Level .
- Click LTS1 Revenue in the Logical Table Source field. Double-click Physical Column, expand F1 Revenue, and then select Revenue.
- In Aggregation, click Add Aggregation by Level . From the Dimension list, click D2 Products. From the Logical Level list, click Total, and then click Save .
- In the F1 Revenue Columns tab, click Add Column .
- In Name, enter
Product Type Revenue
. - In Sources with Physical Expression selected, click Add Level .
- Click LTS1 Revenue in the Logical Table Source field. Double-click Physical Column, expand F1 Revenue, and then select Revenue.
- In Aggregation, click Add Aggregation by Level . From the Dimension list, click D2 Products. From the Logical Level list, click Product Type and then click Save .
Create a Share Measure
In this section, you create a measure that calculates the revenue share of a product type in the total revenue.
- In the F1 Revenue Columns tab, click Add Column . Enter
Product Share
to replace New Column_1. Click Detail View . - Click Logical Expression, and then click Open Expression Editor .
- In the Expression Editor search bar, enter
Round
, and then double-click ROUND to add the function. In the expression field after ROUND in the parentheses, enter the following:(100*Revenue/Product Type Revenue, 1)
- Click Validate, and the click Save in the Expression Editor.
- Click the Presentation Layer , expand Sample Sales, double-click the Base Facts presentation table.
- Click the Logical Layer , expand F1 Revenue, hold down the Ctrl key and drag the following to the Base Facts Columns tab:
- Actual Unit Price
- Product Share
- Product Total Revenue
- Product Type Revenue
- Revenue Rank
- Click Save
Deploy and Validate the Changes
In this section, you run the consistency checker, deploy the updated semantic model, and create a workbook with the updated Sample Sales subject area.
- Click the Consistency Checker and select Include Warnings.
Oracle Analytics didn't find any errors in the Sample Sales semantic model.
- In the semantic model, click the Page Menu , and select Deploy.
The message, "Deploy successful" appears when the deployment process is complete.
- Click Go back . On the Semantic Models page, click Navigator , and then click Home.
- On the Home page, click Create, and then click Workbook.
- In Add Data, click Sample Sales, and then click Add to Workbook.
- In the Data panel, expand the Products and Base Facts folders.
- Hold down the Ctrl key, select Product from Products, and then select Revenue, Revenue Rank, Units, and Actual Unit Price from Base Facts.
- Right click one of the selected data elements, select Pick Visualization, and then select Table.
Next Steps
Learn More
Create Calculated, Level-based, and Share Measures in Oracle Analytics Semantic Modeler
F57738-05
November 2023
Copyright © 2023, Oracle and/or its affiliates.
Learn how to create calculated, level-based, and share measures in the logical layer of a semantic model in Oracle Analytics.
This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited.
If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it on behalf of the U.S. Government, then the following notice is applicable:
U.S. GOVERNMENT END USERS: Oracle programs (including any operating system, integrated software, any programs embedded, installed or activated on delivered hardware, and modifications of such programs) and Oracle computer documentation or other Oracle data delivered to or accessed by U.S. Government end users are "commercial computer software" or "commercial computer software documentation" pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As such, the use, reproduction, duplication, release, display, disclosure, modification, preparation of derivative works, and/or adaptation of i) Oracle programs (including any operating system, integrated software, any programs embedded, installed or activated on delivered hardware, and modifications of such programs), ii) Oracle computer documentation and/or iii) other Oracle data, is subject to the rights and limitations specified in the license contained in the applicable contract. The terms governing the U.S. Government's use of Oracle cloud services are defined by the applicable contract for such services. No other rights are granted to the U.S. Government.
This software or hardware is developed for general use in a variety of information management applications. It is not developed or intended for use in any inherently dangerous applications, including applications that may create a risk of personal injury. If you use this software or hardware in dangerous applications, then you shall be responsible to take all appropriate fail-safe, backup, redundancy, and other measures to ensure its safe use. Oracle Corporation and its affiliates disclaim any liability for any damages caused by use of this software or hardware in dangerous applications.
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
Intel and Intel Inside are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks are used under license and are trademarks or registered trademarks of SPARC International, Inc. AMD, Epyc, and the AMD logo are trademarks or registered trademarks of Advanced Micro Devices. UNIX is a registered trademark of The Open Group.
This software or hardware and documentation may provide access to or information about content, products, and services from third parties. Oracle Corporation and its affiliates are not responsible for and expressly disclaim all warranties of any kind with respect to third-party content, products, and services unless otherwise set forth in an applicable agreement between you and Oracle. Oracle Corporation and its affiliates will not be responsible for any loss, costs, or damages incurred due to your access to or use of third-party content, products, or services, except as set forth in an applicable agreement between you and Oracle.