Skip to main content

Examples of use


Calculation of total product rate​

In the following example, a processing package will be created, and then the total product rate will be calculated using the SDO aggregate.

The total product rate is calculated based on the formula: Base rate x Duty rate.

The accepted rates can be found in the table:

CountryFoodElectronicsClothesToys
Germany5%10%10%4%
France5%10%10%4%
China20%14%15%6%

For the task, the product data will be extracted from an XML file that contains several products.

image

<RECORD>
<Products>
<Product Name="Milk" Category="Food" Country="Germany" BaseRate="4.50"/>
<Product Name="TV LED 43&quot;" Category="Electronics" Country="France" BaseRate="1200.00"/>
<Product Name="Winter jacket" Category="Clothes" Country="Germany" BaseRate="300.00"/>
<Product Name="Interactive doll" Category="Toys" Country="France" BaseRate="95.00"/>
<Product Name="Smartfon X20" Category="Electronics" Country="China" BaseRate="1600.00"/>
<Product Name="Jasmine rice 1kg" Category="Food" Country="China" BaseRate="6.80"/>
</Products>
</RECORD>

Create a package​

  1. Create a processing package consisting of an input block Trivial XML Input File file and a Browse Data block.

image

  1. Load the file (+Add sample XML) in the XML file download block.
  2. Drag the Products record to the right side of the window.

image

  1. The data schema will also be displayed on the Schemas tab.

image

Define a data space​

  1. Create a data space.
  2. Add a Random Data Generator block and an Output port.

image

  1. Go to the Random Data Generator block and create a data schema as below.

image

  1. You can copy the fields from the earlier package, where you took the data from the XML file, and paste them into the schema in the Random Data Generator block.

image

Create a multidimensional table​

  1. Create an SDO element multidimensional table.

image

  1. Set the input and output path to the Product record. This is also where the aggregate will be stored.

image

  1. Fill in the horizontal key. Enter the name Country. In the vertical key, enter the name Category. The key names must exactly reflect the field names from the data schema.

image

  1. Add and complete more horizontal keys. Right click and select Add below.

image

  1. Horizontal keys should be defined this way.

image

  1. Add vertical keys by right-clicking and selecting Add after.

image

The table should look as follows:

image

  1. In the individual cells, enter the rules for calculating the aggregate, appropriate for each key. Type the rule directly in the cell or on the Details panel.

image

  1. If the formulas for the key data are the same, instead of duplicating them in separate records, we can make the formula split between several records.
  2. Select the records and then click Unlink. Formulas can be split vertically as well as horizontally.

image

  1. After saving the data, the aggregate CalculatingRate will appear in the schema (the name of the aggregate is always the same as the name of the SDO).

image

  1. Add a description to the table.

image

Using SDO in the processing package​

  1. Go to the processing package and add the SDO block and the Browse Data block.

image

  1. Go to the details of the block and select the data space.

image

  1. Select the aggregate.

image

  1. Select the Products record and the Select root button. The fields needed to calculate the aggregate are marked with the corresponding symbol. Thanks to the fact that the structures both in the package and in the data space are identical, we do not need to perform additional mappings.

image

  1. Now you can run the package..

Calculating the age and transactions of a client​

The following example will load the client's data from an XML file, and then the aggregates will calculate the client's age, the sum of the client's transactions and the free amount (income).

The contents of the example file:

image

<RECORD>
<CLIENTS>
<C_NAME>John</C_NAME>
<C_SURNAME>Doe</C_SURNAME>
<C_MONTHLY_EARNINGS>5000.00</C_MONTHLY_EARNINGS>
<C_BIRTH_DATE>2000-02-01</C_BIRTH_DATE>
<C_EMPLOYMENT>Contract</C_EMPLOYMENT>
<TRANSACTIONS T_TITILE="Walmart" T_CATEGORY="Food" T_AMOUNT="300" T_DATE="2025-02-18" />
<TRANSACTIONS T_TITILE="Gas station" T_CATEGORY="Transport" T_AMOUNT="450" T_DATE="2025-02-11" />
<TRANSACTIONS T_TITILE="Walmart" T_CATEGORY="Food" T_AMOUNT="70" T_DATE="2025-02-05" />
<TRANSACTIONS T_TITILE="Energy" T_CATEGORY="Energy" T_AMOUNT="220" T_DATE="2025-02-20" />
<TRANSACTIONS T_TITILE="Restaurant" T_CATEGORY="Food" T_AMOUNT="440" T_DATE="2025-02-24" />
<TRANSACTIONS T_TITILE="Walmart" T_CATEGORY="Food" T_AMOUNT="300" T_DATE="2023-11-15" />
<TRANSACTIONS T_TITILE="Gas station" T_CATEGORY="Transport" T_AMOUNT="450" T_DATE="2024-11-28" />
<TRANSACTIONS T_TITILE="Walmart" T_CATEGORY="Food" T_AMOUNT="70" T_DATE="2024-01-12" />
<TRANSACTIONS T_TITILE="Energy" T_CATEGORY="Energy" T_AMOUNT="220" T_DATE="2024-02-08" />
<TRANSACTIONS T_TITILE="Restaurant" T_CATEGORY="Food" T_AMOUNT="440" T_DATE="2024-12-08" />
</CLIENTS>
</RECORD>

Create a package​

  1. Create a processing package consisting of an input block Trivial XML Input File file and a Browse Data block.

image

  1. Load the file (+Add sample XML) in the XML file download block.
  2. Drag the CLIENTS record to the right side of the window..

image

Define a data space​

  1. Create a data space.
  2. Add the Random Data Generator block and the Output port.

image

  1. Go to the Random Data Generator block and create a data schema as below.
  2. You can copy the fields from the earlier package, where you took the data from the XML file, and paste them into the schema in the Random Data Generator block.

image

Creating a multidimensional table​

  1. Create an SDO element multidimensional table.

  2. Mark Key 1 as the output.

image

  1. Click on Key 2 and select Ignore. In this case, we will not use the horizontal key.

image

  1. Enter the names of the aggregates in the left column, and the rules for each aggregate in the right column.

image

The table should look as follows:

SumTransactions: from TRANSACTIONS select sum(T_AMOUNT)

Age: Floor(DateDiff_Months(C_BIRTH_DATE,DateTimeNow())/12)

AmountFree: C_MONTHLY_EARNINGS - SumTransactions

Once the table is saved, the aggregates will be added to the data schema.

image

Using SDO in the processing package​

  1. Go to the processing package and add the SDO block and the Browse Data block.

image

  1. Go to the block details and select the data space and aggregate group.

image

  1. Select the CLIENT record and press Select root. Start the processing package.

image

  1. In the Browse Data block, you can preview the calculated aggregates.

image

Next section: Workflow

See also​

Data space

Multidimensional table

What is SDO