How to Calculate a Unit Price

This article explains how we can calculate a price for 1 unit and perform a division.

Goal: we want to find out how much we pay for 1 item.

Initial data:

{

  "row_total": 250,

  "qty": 2

}

Create a new transformer: Connections -> transformers -> + for a new one

Data, transform data using mappers and conditions 

Transformer: copy using a pattern -> Pattern* - row_total -> Replacement* - unit_price.0

Transformer: copy using a pattern -> Pattern* - qty -> Replacement* - unit_price.1

 

Now we have 2 choices:

1)

Transformer: Value mapper -> pattern accessor -> Pattern* - unit_price

Mapper: Operator -> Division 

OR

2) 

Transformer: Operator Transformer -> Operator - Division -> Data Container Left Path* - unit_price.0 -> Data Container Right Path* - unit_price.1 -> Data Container Destination Path (default left) - unit_price