# AML Extend > This document describes how to use AML Extend to enhance reusability in Holistics projects ## Introduction AML Extend is a function that is applied to an analytics object to produce a new object that takes on the original properties. Consider the following example where a User model is extended for two use cases with different requirements: ```aml Model users { // Details of these dimensions are omitted for brevity dimension id {} dimension email {} dimension signed_up_at {} dimension first_logged_in {} } // Extend Users model and add a new dimension `activated_at` // highlight-next-line Model activatedUsers = users.extend({ // Details of this dimension are omitted for brevity dimension activated_at {}, }) // Extend Users model and hide the dimension `email` from end users // highlight-next-line Model anonymizedUsers = users.extend({ dimension email { hidden: true } }) ``` Without AML Extend, you would have to duplicate the model code multiple times, which is error-prone and requires careful maintenance. ## Syntax ```aml = .extend({ // properties to add or override }) ``` ## Reuse extended logic with AML Partials When you want to **reuse the extended logic**, you can use **[AML Partial](/reference/aml/partial)**, which represents a partial AML object. For example, you can create a `PartialDataset` that contains a bunch of metrics, then reuse them in other datasets, like below: ```tsx // Define a Partial Type of Dataset which contains a group of metrics PartialDataset revenue_metrics { metric gmv { ... } metric mrr { ... } metric arr { ... } } // In company.dataset.aml Dataset company_with_revenue = company.extend(revenue_metrics) // In store.dataset.aml Dataset store_with_revenue = store.extend(revenue_metrics) ``` AML Partials ensure that the extended object structure matches the type of the target object, thus improving correctness. Many Holistics' built-in types support AML Partial: `PartialModel`, `PartialTableModel`, `PartialQueryModel`, `PartialDataset`, `PartialDashboard`, `PartialVizBlock`, `PartialPageTheme` and `PartialBlockTheme`. ## Override nested properties You can extend an object and add or modify only the properties that you're interested in, without having to re-declare other required properties. Let's say that you have a data model for employees that contains sensitive salary information. Certain HR team members request data about current employees, including joining dates, to celebrate their anniversaries. But they don't need the salary dimension and are not authorized to access such information. You can extend the original model and hide away the salary dimension by overriding the `hidden` attribute only. ```tsx // This model contains sensitive employee salary information Model employeeInfo { dimension salary { label: 'Salary' type: 'number' hidden: false definition: @sql {{ #SOURCE.salary }} ;; } dimension joining_date { label: 'Joining Date' type: 'date' hidden: false definition: @sql {{ #SOURCE.joining_date }} ;; } } // This model is exposed to HR team members that need just enough info // to celebrate employee anniversaries // highlight-next-line Model employeeInfoWithoutSalary = employeeInfo.extend({ dimension salary { // override hidden property without having to re-declare other properties // highlight-next-line hidden: true } }); ``` :::caution Extend cannot be used to remove properties Extend cannot be used to completely remove properties from objects. The above example only hides the dimension away by modifying its existing hidden property. ::: ## See also - [AML Reusability Overview](/as-code/aml/reusability-overview) - Conceptual overview and use cases - [AML Partial](/reference/aml/partial) - Extract shared logic for reuse