Typecast derived types - Smart API Connector for Power BI - - Help - Hexagon PPM

Smart API Connector for Power BI Help

PPMProduct
Smart API Connector for Power BI
PPMCategory_custom
Help

The sample Smart API shown here has the following inheritance scheme, shown logically, and then in $metadata:

Pipe (derives from) →Equipment (derives from) →PlantItem (derives from) →PbsItem

<EntityType Name="PbsItem" BaseType="Com.Ingr.Core.V1.DynamicEdmEntityObject"

Abstract="true" OpenType="true">

<EntityType Name="PlantItem" BaseType="Com.Ingr.Core.V1.PbsItem"

Abstract="true" OpenType="true" />

<EntityType Name="Equipment" BaseType="Com.Ingr.Sppid.V1.PlantItem"

Abstract="true" OpenType="true">

<EntityType Name="Pipe" BaseType="Com.Ingr.Sppid.V1.Equipment"

OpenType="true">

Typically, a client appends a type-cast URL segment to limit response data (based on a derived type). For example, to limit a query for PlantItems to Pipes:

GET https://<server>/Sppid/v3/Sites(‘Id’)/Plants(‘Id’)/PlantItems/Com.Ingr.Sppid.V3.PipeBase/

PBI Desktop’s basic support for OData does not include using type-cast URL segments. However, you can use the connector SmartAPIOData.Typecast function to support OData typecasting.

This function must be used in the Advanced Editor by editing Power Query M language and including the typecast.

The following steps provide an overview:

  1. After you connect to a Smart API, the Navigator dialog box shows all available OData entity sets.

  2. Select an entity set that serves as a base type for other derived entity types and click Transform Data to load the Power Query Editor.

    Certain Smart APIs use the multi-tenant pattern that exposes a single entity set at the service root, for example, Sites. In this case, you must navigate to the desired entity set after selecting and loading the single entity set.

    You must be familiar with the inheritance scheme for the entities in the Smart API. See the specific Smart API $metadata document or API documentation for details.

    In this example, the Sites/Plants/PlantItems entity set is used.

  3. Click the View tab, and then Advanced Editor. The editor displays something similar to the following:

    The query for the Sites/Plants/PlantItems navigation property collection stores the result in #"Plant A".

  4. Modify the code in the Advanced Editor to typecast that result using the HexagonSmartApiOData.Typecast function.

  5. Click Done. The table updates to display only Pipe derived types.