# Filter Insights

**URL:** <https://community.silverfin.com/t/filter-insights/1581>\
**Category:** Insights\
**Created:** [October 10, 2019, 8:28am UTC](https://community.silverfin.com/t/filter-insights/1581 "2019-10-10T08:28:19Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlexanderDB](https://avatars.discourse-cdn.com/v4/letter/a/74df32/32.png) [@AlexanderDB](https://community.silverfin.com/u/AlexanderDB)\
**Post date:** [October 10, 2019, 8:28am UTC](https://community.silverfin.com/t/filter-insights/1581/1 "2019-10-10T08:28:19Z")

</div>

Hi,

I’m trying to make a (combined) Filter within Insights that sould give me the following result:

_list of all companies in which there is at least 1 shareholder a natural person_

I’m not sure which person.drops I have to use to make this filter.  
Can someone help me with this?

Thanks

---

<div class="post-metadata">

**Author:** ![sven](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/sven/32/1495_2.png) [@sven](https://community.silverfin.com/u/sven)\
**Post date:** [October 10, 2019, 9:27am UTC](https://community.silverfin.com/t/filter-insights/1581/2 "2019-10-10T09:27:26Z")

</div>

Hi @AlexanderDB,

Nice case!

The thing that I would do, is to create an additional reconciliation template that can then be used for all kinds of queries. Because the amount of shareholders, can be accessed in any template by doing this:

```auto
{{ period.shareholders.count }} 

```

but you cannot access that directly in Insights. So a workaround is needed, where you create a specific template (or add the code in another template, as what we’ll do is in the background anyway so no user will ever notice it), and then take that value into a result-tag:

```auto
{% comment %}value shareholders needed for SF INSIGHTS{% endcomment %}
{% result 'amount_shareholders' period.shareholders.count %} 

```

That way, you can access that result tag with the filter “Reconciliation data”.

Let me know if it works out. Nice case 👍

---

<div class="post-metadata">

**Author:** ![AlexanderDB](https://avatars.discourse-cdn.com/v4/letter/a/74df32/32.png) [@AlexanderDB](https://community.silverfin.com/u/AlexanderDB)\
**Post date:** [October 11, 2019, 9:25am UTC](https://community.silverfin.com/t/filter-insights/1581/3 "2019-10-11T09:25:54Z")

</div>

Sven,

Can I also filter on shareholders who are natural persons?  
In some cases, all of the shareholders are legal persons, f.e. in holding companies. I don’t want those companies in my result.

---

<div class="post-metadata">

**Author:** ![sven](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/sven/32/1495_2.png) [@sven](https://community.silverfin.com/u/sven)\
**Post date:** [October 11, 2019, 9:29am UTC](https://community.silverfin.com/t/filter-insights/1581/4 "2019-10-11T09:29:14Z")

</div>

@AlexanderDB,

Yes, but then you need to loop over all shareholders where the type is set on “natural” (more info [here](https://community.silverfin.com/t/case-overview-legal-data-from-silverfin-templates/1580) how those database vars are called)  
In each loop, you can then do this eg:

```auto
{% assign count_nat_shareholders = count_nat_shareholders | plus:1 %}

```

and then take that value into a result-tag.

---

<div class="post-metadata">

**Author:** ![AlexanderDB](https://avatars.discourse-cdn.com/v4/letter/a/74df32/32.png) [@AlexanderDB](https://community.silverfin.com/u/AlexanderDB)\
**Post date:** [October 15, 2019, 1:18pm UTC](https://community.silverfin.com/t/filter-insights/1581/5 "2019-10-15T13:18:45Z")

</div>

Sven,  
thx for the reply:

I think that following code sould do the trick?

` {% for person in period.people %} {% if person.custom.type !="legal" and person.shareholder == "true" %} {% assign count_nat_shareholders = count_nat_shareholders | plus:1 %} {% endif %} {% endfor %}`

---

<div class="post-metadata">

**Author:** ![sven](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/sven/32/1495_2.png) [@sven](https://community.silverfin.com/u/sven)\
**Post date:** [October 15, 2019, 1:49pm UTC](https://community.silverfin.com/t/filter-insights/1581/6 "2019-10-15T13:49:11Z")

</div>

Hi @AlexanderDB,

Not entirely correct; I’d use this:

```auto
{% for person in period.people %}
  {% comment %}check what type has been set in BEDRIJFSPARAMETERS by the db var "person.custom.type"{% endcomment %}
  {% if person.custom.represented_by_name != blank %}
    {% assign default_type = "legal" %}
  {% else %}
    {% assign default_type = "nature" %}
  {% endif %}
  {% assign type = person.custom.type | default:default_type %}  
  {% if type != "legal" and person.shareholder == true %} 
    {% assign count_nat_shareholders = count_nat_shareholders | plus:1 %}
  {% endif %}
{% endfor %}

```

The dropdown for type of person (legal or not) is with a default. So even if you see “legal” selected, that can mean the database variable can be in fact empty.

---

<div class="post-metadata">

**Author:** ![AlexanderDB](https://avatars.discourse-cdn.com/v4/letter/a/74df32/32.png) [@AlexanderDB](https://community.silverfin.com/u/AlexanderDB)\
**Post date:** [October 15, 2019, 2:19pm UTC](https://community.silverfin.com/t/filter-insights/1581/7 "2019-10-15T14:19:32Z")

</div>

Sven,

Code mentioned above did the trick!

Thanks

---

<div class="post-metadata">

**Author:** ![sven](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/sven/32/1495_2.png) [@sven](https://community.silverfin.com/u/sven)\
**Post date:** [October 15, 2019, 2:21pm UTC](https://community.silverfin.com/t/filter-insights/1581/8 "2019-10-15T14:21:07Z")

</div>

Closed on October 15, 2019, 2:21pm UTC



---

<div class="post-metadata">

**Author:** ![sven](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/sven/32/1495_2.png) [@sven](https://community.silverfin.com/u/sven)\
**Post date:** [October 15, 2019, 2:21pm UTC](https://community.silverfin.com/t/filter-insights/1581/9 "2019-10-15T14:21:36Z")

</div>

You’re welcome!
