> Documentation index: https://www.gooddata.ai/docs/gooddata-ui/llms.txt lists every page of these docs as Markdown.

# MeasureBuilderBase

- Package: [@gooddata/sdk-model](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/index.md)
- Kind: class
- Source: https://github.com/gooddata/gooddata-ui-sdk/blob/rel/11.64/libs/sdk-model/src/execution/measure/factory.ts

Abstract base class for measure builders. Measure builders allow for incremental, fluent construction and modification of measures.

**Signature:**

```typescript
export declare abstract class MeasureBuilderBase<T extends IMeasureDefinitionType> 
```

## Remarks

You should not be instantiating the builders directly. Instead, rely on the different functions to create different types of measures.

The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `MeasureBuilderBase` class.

## Properties

| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [alias](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.measurebuilderbase/index.md#measurebuilderbasealias) |  | (alias?: string) =&gt; this | Sets alias - alternative title - for the measure. |
| [build](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.measurebuilderbase/index.md#measurebuilderbasebuild) |  | () =&gt; [IMeasure](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.imeasure/index.md)&lt;T&gt; |  |
| [customLocalId](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.measurebuilderbase/index.md#measurebuilderbasecustomlocalid) | `protected` | boolean |  |
| [defaultFormat](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.measurebuilderbase/index.md#measurebuilderbasedefaultformat) |  | () =&gt; this | Resets format string to the server-defined value. |
| [defaultLocalId](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.measurebuilderbase/index.md#measurebuilderbasedefaultlocalid) |  | () =&gt; this | Indicates that the measure's localId should be generated using the default local-id generator logic. |
| [format](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.measurebuilderbase/index.md#measurebuilderbaseformat) |  | (format?: string) =&gt; this | Sets measure format to use when rendering values calculated from this measure. |
| [localId](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.measurebuilderbase/index.md#measurebuilderbaselocalid) |  | (localId?: [Identifier](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.identifier/index.md)) =&gt; this | Sets local identifier (localId) for the measure. LocalId can be used to reference the measure within the execution definition. |
| [noAlias](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.measurebuilderbase/index.md#measurebuilderbasenoalias) |  | () =&gt; this | Resets alias - alternative title - set for the measure. |
| [noTitle](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.measurebuilderbase/index.md#measurebuilderbasenotitle) |  | () =&gt; this | Resets alternative title for the measure. The server-defined title of the measure will be used instead. |
| [title](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.measurebuilderbase/index.md#measurebuilderbasetitle) |  | (title?: string) =&gt; this | Sets alternative title for the measure. |

## Methods

| Method | Modifiers | Description |
| --- | --- | --- |
| [buildDefinition()](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.measurebuilderbase/index.md#measurebuilderbasebuilddefinition) | `protected` `abstract` | Build of measure definition is responsibility of the subclass. |
| [generateLocalId()](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.measurebuilderbase/index.md#measurebuilderbasegeneratelocalid) | `protected` `abstract` | Generation of local identifier is a responsibility shared with the the subclass - so that the concrete builders can use their concrete definition to provide additional parts of the local id. |
| [initializeFromExisting(measure)](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.measurebuilderbase/index.md#measurebuilderbaseinitializefromexisting) | `protected` | The measure builder subclasses must call this when they are used to modify an existing measure. Existing measure modification returns a new object that reflects the mods however it keeps the localId set as-is. |

## Property details

### MeasureBuilderBase.alias

Sets alias - alternative title - for the measure.

**Signature:**

```typescript
alias: (alias?: string) => this;
```

#### Remarks

This value will then be used in various chart-specific descriptive elements. For convenience if no alias is specified, the measure will fall back to using either title (if specified) or server-defined title as the ultimate fallback

### MeasureBuilderBase.build

**Signature:**

```typescript
build: () => IMeasure<T>;
```

### MeasureBuilderBase.customLocalId

**Signature:**

```typescript
protected customLocalId: boolean;
```

### MeasureBuilderBase.defaultFormat

Resets format string to the server-defined value.

**Signature:**

```typescript
defaultFormat: () => this;
```

### MeasureBuilderBase.defaultLocalId

Indicates that the measure's localId should be generated using the default local-id generator logic.

**Signature:**

```typescript
defaultLocalId: () => this;
```

### MeasureBuilderBase.format

Sets measure format to use when rendering values calculated from this measure.

**Signature:**

```typescript
format: (format?: string) => this;
```

#### Remarks

The format string is described in more detail here [https://help.gooddata.com/doc/en/reporting-and-dashboards/reports/working-with-reports/formatting-numbers-in-reports](https://help.gooddata.com/doc/en/reporting-and-dashboards/reports/working-with-reports/formatting-numbers-in-reports).

For convenience, if you do not specify any format, then a default server-defined value will be used instead.

### MeasureBuilderBase.localId

Sets local identifier (localId) for the measure. LocalId can be used to reference the measure within the execution definition.

**Signature:**

```typescript
localId: (localId?: Identifier) => this;
```

#### Remarks

Normally, builder will generate localId based on contents of the measure definition - taking all properties into account: in typical scenarios you don't have to call this function at all. The only exception where you have to provide custom local id is if your execution must contain the exact same measure twice.

For convenience, this method also accepts 'undefined', which indicates that the default local id generation logic should be used.

### MeasureBuilderBase.noAlias

Resets alias - alternative title - set for the measure.

**Signature:**

```typescript
noAlias: () => this;
```

#### Remarks

The measure title will be used if specified, otherwise the server-defined title will be used instead.

### MeasureBuilderBase.noTitle

Resets alternative title for the measure. The server-defined title of the measure will be used instead.

**Signature:**

```typescript
noTitle: () => this;
```

### MeasureBuilderBase.title

Sets alternative title for the measure.

**Signature:**

```typescript
title: (title?: string) => this;
```

#### Remarks

This value will then be used in various chart-specific descriptive elements. For convenience if no title is specified, the measure will fall back to server-defined value.

## Method details

### MeasureBuilderBase.buildDefinition()

Build of measure definition is responsibility of the subclass.

**Signature:**

```typescript
protected abstract buildDefinition(): T;
```
**Returns:**

T

new instance

### MeasureBuilderBase.generateLocalId()

Generation of local identifier is a responsibility shared with the the subclass - so that the concrete builders can use their concrete definition to provide additional parts of the local id.

**Signature:**

```typescript
protected abstract generateLocalId(): string;
```
**Returns:**

string

local identifier

### MeasureBuilderBase.initializeFromExisting()

The measure builder subclasses must call this when they are used to modify an existing measure. Existing measure modification returns a new object that reflects the mods however it keeps the localId set as-is.

**Signature:**

```typescript
protected initializeFromExisting(measure: MeasureEnvelope): void;
```

#### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| measure | [MeasureEnvelope](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.measureenvelope/index.md) | envelope of measure being modified |

**Returns:**

void
