Account selector, prior year value not show when current year value is 0

Hello there,

Please see my coding below, could you please advise why when I select an account, if this account current year is 0, but prior year has a value, the result will be both current year value and prior year value are not print out, seems like the system just skip that account?

{% assign additional_items_range  = additional_items_range  | default:"1491,1492,1591,1592,2491,2492,2591,2592,3991,3992" %}
{% stripnewlines %}
|{% input custom.additional_items.toSelect as:account_collection range:additional_items_range accounts_var:additional_items | currency_dc %}
{% newline %}
{% for additional in additional_items %}
{% ic %}|{% endic %}
|{% capture additional_account_link %}{% linkto additional %}{{ additional.original_number }} {{ additional.name }}{% endlinkto %}{% endcapture %}
{{ additional_account_link }}
{% assign additional_cy_end = period.accounts.include_zeros | range:additional.number %} 
{% assign additional_py_end = period.minus_1y.accounts | range:additional.number %} 
**{{ additional_account_name }}**
|**{{ additional_cy_end | currency:0 }}**
|**{{ additional_py_end | currency:0 }}**
{% newline %}
{% endfor %}
{% endstripnewlines %}

Thank you!

Hi @Flora,

Thanks for your question. You actually are halfway there, as I see you are familiar with the include_zeros method.

Now, you created a collection of accounts in additional_items, and that collection will look at all accounts having a value (different than zero) in the current period. So if an account doesn’t have a value different than zero (but it does in previous year/periods), it won’t be taken into your logic and simply won’t show up.

How to fix this? Well, you’ll need to make sure all accounts of current period are taken into consideration, including the ones with a value zero. And you can do that with adding the method include_zeros into your collection:

{% for additional in additional_items.include_zeros %}
... 
{% endfor %}

Hope this helps?

PS do note it is better to use the mapped_number variable instead of the number, as that number can be different than you’d expect.
More info here:

I also fine-tuned your code a bit for the value of the account in current period, as you don’t need to create that with a filter on the period.accounts drop.

You can just do:

{% assign additional_cy_end = additional.value %}

Here it is completed:

{% stripnewlines %}
{% for additional in additional_items.include_zeros %}
{% ic %}|{% endic %}
|{% capture additional_account_link %}{% linkto additional %}{{ additional.original_number }} {{ additional.name }}{% endlinkto %}{% endcapture %}
{{ additional_account_link }}
{% assign additional_cy_end = additional.value %} 
{% assign additional_py_end = period.minus_1y.accounts | range:additional.mapped_number %} 
**{{ additional_account_name }}**
|**{{ additional_cy_end | currency:0 }}**
|**{{ additional_py_end | currency:0 }}**
{% newline %}
{% endfor %}
{% endstripnewlines %} 
1 Like

Thank you Sven, this solution works for me!