Collection

Map

This filter will create an array of items taking from a collection using the given argument.

🚧

{{ period.accounts }} is a collection that holds all used accounts of the current period. When adding "613" to it, {{ period.accounts.613 }}, it'll filter down to all used accounts of the given range 613, with info like name, number, value, ...

{% assign used_accounts = period.accounts.613 | map:"number" | join:", " %}

{{ used_accounts }}
Output
613130, 613510, 613540

Range

This will filter an account collection on a specific range given as a argument. The range can be given as a string between double quotes "".

{% assign profit = period.accounts | range:"6,7" %}

{{ profit.value | currency }}
Output
-6,897.00

This will take all inputted years and only filter on the ones that have '2020' in them for that specific database variable 'custom.year'.

Group by

The group_by filter provides the possibility to group items of the collection that have the same value for a specific variable.

{% stripnewlines %}
|----|---|---# {% newline %}
{% fori share in custom.shares %}
  | {% input share.name %}
  | {% input share.type as:select options:"A|B|C" %}
  | {% input share.value as:currency %}
  {% newline %}
{% endfori %}
{% endstripnewlines %}

{% assign grouped_shares = custom.shares | group_by:"type" %}

B aandelen

{% for share in grouped_shares["B"] %}
  {{ share.name }} {{ share.value }}
{% endfor %}

Let's assume that we filled in some data as shown below. Then the above code will give the following result:

Output

You can find an example of the group_by filter on our community.

Index by

The index_by filter makes it possible to access a collection item through another index then you are used to.

The community provides a perfect example on how to implement this.

❗️

When 2 items of a collection have the same index, only the last item will be called upon when that index is used.