# Ifi does'nt work in fori

**URL:** <https://community.silverfin.com/t/ifi-doesnt-work-in-fori/1973>\
**Category:** Exports\
**Tags:** export\
**Created:** [December 11, 2020, 9:15am UTC](https://community.silverfin.com/t/ifi-doesnt-work-in-fori/1973 "2020-12-11T09:15:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![VVAcc](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/vvacc/32/1603_2.png) [@VVAcc](https://community.silverfin.com/u/VVAcc)\
**Post date:** [December 11, 2020, 9:15am UTC](https://community.silverfin.com/t/ifi-doesnt-work-in-fori/1973/1 "2020-12-11T09:15:53Z")

</div>

I want to use an ifi to hide a part of our letter if no data is in the fori. The fori works fine, but when I export the letter to pdf, the part with the data I input is never visible.

![image](https://canada1.discourse-cdn.com/flex030/uploads/getsilverfin/original/2X/1/140c7878934443c648780493b47ad81ec8108087.png)

![image](https://canada1.discourse-cdn.com/flex030/uploads/getsilverfin/original/2X/1/12012f7ac1ae36cb1a8267ccdd39fd16e49f6cbe.png)

How do I have to implement the ifi to work with the fori in the table?

{% ifi VAA.Soort != blank %}  
Volgende voordelen betreffende het privégebruik van bepaalde bedrijfsgoederen of –kosten werden reeds aangeven aan de fiscus:

{% stripnewlines %}  
| Aard voordeel  
| Bedrag  
{% newline %}  
|:----30%----  
|-----30%—:  
{% newline %}  
{% fori VAA in company.custom.voordeel %}  
| {% input VAA.Soort %}  
| {% input VAA.Bedrag as:currency %}{% newline %}  
{% endfori %}  
{% endstripnewlines %}  
{% endifi %}

---

<div class="post-metadata">

**Author:** ![robindeclercq](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/robindeclercq/32/472_2.png) [@robindeclercq](https://community.silverfin.com/u/robindeclercq)\
**Post date:** [December 11, 2020, 9:51am UTC](https://community.silverfin.com/t/ifi-doesnt-work-in-fori/1973/2 "2020-12-11T09:51:54Z")

</div>

Hi @VVAcc,

So in general the use of the `ifi`-statement is the correct way to approach this. The only issue is the content of the `ifi`-statement. Currently you are trying to check if a variable with namespace VAA and key Soort is blank. However, this variable does not exist. What does exist is company.custom.voordeel.voordel\_1.Soort as part of the `fori`-loop.

So in order to check if data is included in the column VAA.Soort you should access the fori-loop separately at the top of your code and check if there is data in the column VAA.Soort for any of the rows.

To achieve this, you could add something like this:

> {% assign show\_table = false %}  
> {% for VAA in company.custom.voordeel %}  
> {% if VAA.Soort != blank %}{% assign show\_table = true %}{% endif %}  
> {% endfor %}

And check this show\_table variable in the `ifi`-statement.

> {% ifi show\_table != blank %}

If you only want to hide the table when the fori is completely empty (so not only checking the first column) you could also easily do

> {% ifi company.custom.voordeel != empty %}

One final remark, is there a specific reason you would link this `fori`-loop to the company drop? By doing so, the input fields will not be period specific. Meaning if you add or remove one line in one period, it will also be added or removed in other periods.

Hope this helps!

Kind regards,  
Robin

---

<div class="post-metadata">

**Author:** ![VVAcc](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/vvacc/32/1603_2.png) [@VVAcc](https://community.silverfin.com/u/VVAcc)\
**Post date:** [December 11, 2020, 11:34am UTC](https://community.silverfin.com/t/ifi-doesnt-work-in-fori/1973/3 "2020-12-11T11:34:24Z")

</div>

Hi Robin,

I adjusted as follow and it works fine!

{% assign show\_table = false %}  
{% for VAA in period.custom.voordeel %}  
{% if VAA.Soort != blank %}{% assign show\_table = true %}{% endif %}  
{% endfor %}  
{% ifi period.custom.voordeel != empty %}  
{% stripnewlines %}  
| Aard voordeel  
| Bedrag  
{% newline %}  
|:----30%----  
|-----30%—:  
{% newline %}  
{% fori VAA in period.custom.voordeel %}  
| {% input VAA.Soort %}  
| {% input VAA.Bedrag as:currency %}{% newline %}  
{% endfori %}  
{% endstripnewlines %}  
{% endifi %}

I used ‘company’ because the type of VAA will be the same every period. But because the amount will change I corrected it to ‘period’.

Thx for the help

---

<div class="post-metadata">

**Author:** ![robindeclercq](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/robindeclercq/32/472_2.png) [@robindeclercq](https://community.silverfin.com/u/robindeclercq)\
**Post date:** [December 11, 2020, 12:13pm UTC](https://community.silverfin.com/t/ifi-doesnt-work-in-fori/1973/4 "2020-12-11T12:13:57Z")

</div>

Hi @VVAcc,

If this code is used for a reconciliation or account template, adding `period.` is not even necessary. Every custom is automatically linked to period.

Happy I could help! Good luck with the rest of the template 👍

Kind regards,  
Robin
