<p>This is what I have used, some math and the <a href="https://twig.symfony.com/doc/2.x/filters/slice.html" rel="nofollow noreferrer"><code>slice</code></a> filter.</p>

<pre><code>{% set midIndex = ((entry.myMatrixField|length) / 2)|round - 1 %}

{% set blocksA = entry.myMatrixField|slice(0, midIndex) %}
{% set blocksB = entry.myMatrixField|slice(midIndex, null) %}
</code></pre>

CC BY-SA 4.0
2018-07-04T16:00:35.033Z
For anyone wanting to round up rather than down, the method in the argument is 'ceil'. So it would then be: round(0, 'ceil') ie https://twig.symfony.com/doc/2.x/filters/round.html
Andrew
CC BY-SA 3.0
2017-11-14T16:59:12.467Z
2017-11-14T16:59:12.467Z
carlcs
<p>Is it possible to limit and offset the output of a Matrix field by 50%? I wanted to split the data across two columns. </p>

<matrix>
Limit/offset output of Matrix field by 50%
# Limit/offset output of Matrix field by 50%

(Asked by: username_0 on 2017-11-14)

Is it possible to limit and offset the output of a Matrix field by 50%? I wanted to split the data across two columns.

**Tags:** matrix

---

## 1 answers

### Answer by username_1 on 2017-11-14. Score: 2 | Accepted answer

This is what I have used, some math and the slice filter.
{% set midIndex = ((entry.myMatrixField|length) / 2)|round - 1 %}

{% set blocksA = entry.myMatrixField|slice(0, midIndex) %}
{% set blocksB = entry.myMatrixField|slice(midIndex, null) %}

> **Comments:**
> **username_0**: For anyone wanting to round up rather than down, the method in the argument is 'ceil'. So it would then be: round(0, 'ceil') ie https://twig.symfony.com/doc/2.x/filters/round.html  

---

