---
title: Derivations
slug: ryze/derivations
description: Learn how to create and apply derivations in Medidata Rave with this comprehensive document. Understand the process of creating derivations at the Metadata Version level and applying them at the Section level. Discover how to specify the form and folder p
createdAt: 2023-09-29T10:50:57.840Z
---

Derivations are created in the Methods tab found at Metadata Version level and referenced at Section (ItemRef) level.

To apply a Derivation to a field, complete the ‘Folder’ and ‘Form’ properties in the Method to specify the Form that contains the Section (Item Group) with the ItemRef and the Folder where the Form is contained.

You can apply the Derivation to all instances of the Question within a specified Folder or across all Folders by setting 'Apply to All Fields' to 'true'. If set to 'true', the 'Form' property should not be populated. The 'Folder' property should be populated if the Derivation should only be applied within a particular Folder; it should be left blank if the Derivation should be applied to all instances of the Item across all Folders.

A Derivation is built up from a series of Derivation Steps. Multiple Derivation Steps can be defined by creating additional Custom Elements. The Derivation Steps will be performed in the order that they appear within the Method. This order can be changed by using the 'Ordinal' property within each Derivation Step.

**Note**: A Derivation can only be created if you have not entered the ‘Custom Function Name’ property, as this changes the method from a Derivation to a Custom Function (see Custom Functions). 

## Example Derivation

This example shows how to create a Derivation that calculates the Age based on the current date and  the 'Date of Birth' field.

:::Iframe{code="<iframe src=&#x22;https://player.vimeo.com/video/672706599?h=a4fd8e2ed3&#x22; width=&#x22;640&#x22; height=&#x22;564&#x22; frameborder=&#x22;0&#x22; allow=&#x22;autoplay; fullscreen&#x22; allowfullscreen></iframe>"}

:::

1. From the asset group, clic&#x6B;**&#x20;create Method**
2. Select the Medidata Rave Properties
3. Select the Form containing the variable that the Derivation will be applied to
4. Click **Add Derivation Step group**
5. Create a Data Value Derivation Step for the current date
6. Create a Data Value Derivation Step for the Date of Birth
7. Create a Data Value Derivation Step to calculate Age by selecting the Age Step Function
8. Attach the Method to the 'Age' Question by selecting **Associate** under **Context properties > Method**.

## Custom Functions

A Custom Function is piece of code added to a Medidata Rave Project to extend the functionality of a Derivation or Edit Check.

Some scenarios that require the use of Custom Functions include:

- Looping through repeating forms/ log lines on a form
- Deriving a subject ID that includes the site number
- Performing complex calculations

Custom Functions are defined within Methods at Metadata Version level. The name of the Custom Function should be entered into the 'Custom Function Name' property. No other properties or Custom Elements should be used when defining a Custom Function.

The Custom Function is defined within the Formal Expression within the Method and contains the following components:

- Text: contains the code
- Context: must be in one of the following formats:
  - Rave\:C#
  - Rave\:VB
  - Rave\:SQ

**Note**: These options are the only options supported by Rave. The 'Rave' portion indicates that this Formal Expression should be used for the Custom Function. The portion after the colon indicates which language the Custom Function is written in.

Custom Functions can be used within Derivations and Edit Checks. When referring to the Custom Functions, the value specified in the 'Custom Function Name' property should be used.


