Filter Insights


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?


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:

{{ 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:

{% 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 :+1:


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.


Yes, but then you need to loop over all shareholders where the type is set on “natural” (more info here how those database vars are called)
In each loop, you can then do this eg:

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

and then take that value into a result-tag.

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 %}

Hi @AlexanderDB,

Not entirely correct; I’d use this:

{% 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.


Code mentioned above did the trick!


You’re welcome!