# SUBSET

### Description

Extracts a subset of elements from a given *Vector.*&#x20;

### SUBSET(Vector\<Any>, Scalar\<Number>)

Extract the first or last x entries.

<pre class="language-java"><code class="lang-java"><strong>SUBSET(vector: Vector&#x3C;Any>, x: Scalar&#x3C;Number>): Vector&#x3C;Any>
</strong></code></pre>

#### Parameters

<table><thead><tr><th width="163">Parameter</th><th>Description</th></tr></thead><tbody><tr><td>vector</td><td>A vector of type any.</td></tr><tr><td>x</td><td>A positive or negative number. When x is a positive number it starts to extract the number of entries stated in param2 from the beginning, when param2 is a negative number it starts to extract the number of entries stated in param2 from the end of the vector.</td></tr></tbody></table>

#### Returns

Returns a Vector of type any.

***

### SUBSET(Vector\<any>, Scalar\<Number>, Scalar\<Number>)

```java
SUBSET(vector: Vector<Any>, x: Scalar<Number>, y: Scalar<Number>): Vector<Any>
```

#### Parameters

<table><thead><tr><th width="179">Parameter</th><th>Description</th></tr></thead><tbody><tr><td>vector</td><td>A vector of type any.</td></tr><tr><td>x</td><td>Position from which to start extracting elements. If negative, then position is counted from the end of the vector.</td></tr><tr><td>y</td><td>Position until which to extract elements.  If negative, then position is counted from the end of the vector.</td></tr></tbody></table>

### SUBSET(Vector\<Event>, Scalar\<Time>)

```java
SUBSET(vector: Vector<Event>, start: Scalar<Time>): Vector<Event>
```

Extract entries from time *start* until the latest event (left argument is excluding, right is including)

#### Parameters

<table><thead><tr><th width="179">Parameter</th><th>Description</th></tr></thead><tbody><tr><td>vector</td><td>A vector of type Event.</td></tr><tr><td>start</td><td>The start time from which to start extracting entries until the latest.</td></tr></tbody></table>

#### Returns

A Vector of type Event.

***

### SUBSET(Vector\<Event>, Scalar\<Time>, Scalar\<Time>)

```java
SUBSET(vector: Vector<Event>, start: Scalar<Time>, end: Scalar<Time>): Vector<Event>
```

Extract entries from time *start* until time *end* (left argument is excluding, right is including the time border)

#### Parameters

<table><thead><tr><th width="172">Parameter</th><th>Description</th></tr></thead><tbody><tr><td>vector</td><td>A vector of type Event</td></tr><tr><td>start</td><td>The start time from which to start extracting entries. (Excluded)</td></tr><tr><td>end</td><td>The end time until which to extract entries. (Included)</td></tr></tbody></table>

#### Returns

A Vector of type Event.

### Examples

&#x20;Extract the last entry from the vector *GridPowerConsumption*.

```java
SUBSET($GridPowerConsumption, -1)
```

Extract all events from zero hour (midnight) until now.

```java
SUBSET($GridPowerConsumption, lastZeroHour)
```

Extract all events 2 days ago until 1 day ago.

```java
SUBSET($GridPowerConsumption, now-2d, now-1d)
```
