In order to transform data, we need to create process pipelines. Process pipelines simply have inputs and outputs. They take in one set of data, output another.

We'll need to make two of them, one to calculate the square area, and another to find out which quantity discount to use.

## Pipeline 1: Calculating the square area

Go to **Process pipelines > New...** and create a new process pipeline with the sub-slug `calculate-square-area`

. Here is the code for it.

As you can see, the syntax is the same for process pipelines as for form pipelines.

The first and second steps takes the width and height and converts them into meters using the built-in `length-conversion.r.1`

operation block, and stores that in pipeline values `height-m`

and `width-m`

.

Then, all we do is use `math-basic.r.1`

to multiply them together to get the square area - which we then output on `m2`

!

## Pipeline 2: Finding the next discount percentage break

Now let's create another process pipeline with the slug `get-discount-percentage`

. Here is the code.

#### Step 1 - searching for the right discount percentage

This process pipeline will take in two lists, `min-quantities`

representing the minimum quantity you need to purchase, and the next one, `discount-percentages`

is the corresponding discount percentage.

`Example payload`

min-quantities: discount-percentages:

[ [

1, 0,

10, 20,

100 40

] [

So if we purchase 5 items, we get 0% off, 15 items 20% off, and so on.

We can search number lists by using the operation block `find-list-index-by-number.r.1`

. If we use provide the `condition`

input with the text payloadlet `["equal-or-closest-less"]`

we get the behaviour we are looking for.

If it finds the input `by-number`

according to the condition in `number-list`

it outputs the index of that item, otherwise it outputs null.

#### Step 2 - Making sure we found something

If we haven't set up our data sources correctly, we may end up without a result. So let's make sure we really got one, for this, we can use the `ASSERT`

block.

` {`

"type": "ASSERT",

"inPriority": [

{

"type": "PIPELINE_VALUE",

"inFrom": "index-maybe"

}

],

"fallback": {

"type": "REJECT",

"message": {

"type": "INLINE_VALUE",

"inFrom": {

"dataShape": {

"type": "text",

"nullable": false,

"list": false

},

"data": ["No discount percentage was found."]

}

}

},

"out": [

{

"outTo": "index"

}

]

}

The assert block takes in a list of `inPriority`

items. It begins with the first one and moves down the list until it finds an item which is not nullish.

If all of the items are nullish, we resort to the fallback. In this case we do the `REJECT`

fallback type, which exits the execution of the pipeline, and the also all parent pipelines it may be running within. It can be provided with a `message`

. This is can be from any payloadlet of type `text`

.

You can also provide an assert block with `FALLBACK_DATA`

instead of rejecting. You can read more about the assert block in the rest of our documentation.

Now our "for-sure" index is outputted to a new pipeline value `index`

. This one is now known to be non-nullish.

#### Step 3 - Picking the discount percentage from the other list

Now that we know the corresponding index to the discount percentage, we can use it to pick it out from that list using the operation block `pick-list-item-by-index.r.1`

.

And with that, we have our output: `discount-percentage`

!

## Done!

Now it's time to create a yield pipeline.