如何从一组数据自动生成现金流日期和值?

huangapple go评论75阅读模式
英文:

How to generate Cashflow dates and values automatically from a set of Data?

问题

我正在尝试创建一个用于跟踪我的保险投资回报的工具。

我在第一个表中创建了一个主列表,然后相应地在第二个表中创建了每个保单的现金流。

手动输入现金流的日期这一过程相当繁琐,我相信一定有更好的方式来管理这些信息。

请求您能否查看一下并看看如何创建这个工具?

我已经创建了两种保单,一种在保单期结束时有成熟赔付,另一种是在保险费期满后每年有赔付。

这是 Google 表格的链接 - 您可以查看并创建一个副本。

英文:

So I am trying to create a returns tracker for my Insurance investments.

I have created a master list in the first sheet and accordingly I am creating cashflow of each policy in the 2nd sheet.

This process of manually entering the dates as per the cashflow is quite tedious and I am sure there is a better way to manage this.

Requesting if you can kindly have a look and see how to create this?

I have created 2 policies, 1 with maturity payout at the end of the policy, and another with payouts every year after the premium term.

Here is the link to Google sheet - you can view and create a copy of it.

答案1

得分: 2

这是您要的翻译内容:

This process of manually entering the dates as per the cashflow is quite tedious and I am sure there is a better way to manage this.

这个手动输入现金流日期的过程相当繁琐,我相信肯定有更好的管理方式。

Example: Policy XXXX1245S

  1. "Year" column is a range of dates.
    • First date is the "Start Date" in Cashflow sheet'!J5
    • Dates increment by 1 year
    • Final date is x years after the "Start Date" where x = "Policy term" Cashflow sheet'!J9
  2. Outflow is a number based on the "Premium amount" Cashflow sheet'!J3
    • Outflow is included on the "Start Date" and for y more years, where y = "Prem. pmt term" Cashflow sheet'!J8

示例:保单 XXXX1245S

  1. “年” 列是一系列日期。
    • 第一个日期是 Cashflow sheet'!J5 中的 “开始日期”
    • 日期每年递增
    • 最后的日期是 “开始日期” 后的 x 年,其中 x = “保单期限” Cashflow sheet'!J9
  2. 支出是基于 “保费金额” Cashflow sheet'!J3 的数字
    • 支出包括在 “开始日期” 上,以及 y 年,其中 y = “保费支付期” Cashflow sheet'!J8

Named Ranges
To make the formula easier to follow I've used named ranges

命名范围
为了使公式更容易理解,我使用了命名范围

Formula
The following formula will dynamically create the first three columns 如何从一组数据自动生成现金流日期和值? with as many rows as is required and properly populated. If the logic for the "Inflow" column was better understood, it too could be populated in the same formula. Frankly, the entire table including the information at the top could probably be populated from one formula based solely on the "Policy No." if all the required data is stored in the Master List sheet.

公式
以下公式将根据需要动态创建前三列如何从一组数据自动生成现金流日期和值?,并适当填充行数。如果更好地理解了**“流入”列的逻辑,它也可以在同一个公式中填充。坦白说,整个表格,包括顶部的信息,如果所有所需数据都存储在Master List表中,那么可能可以从一个仅基于“保单号”**的公式中填充。

Additional Info
The SEQUENCE function creates an array of specified dimensions, populated with a number sequence starting at a specified value, and incrementing (stepping) by another specified value. The only required value, however, is rows (height).

附加信息
SEQUENCE 函数创建一个具有指定维度的数组,以从指定值开始的数字序列填充,并逐步增加(步进)到另一个指定值。然而,唯一必需的值是行数(高度)。

The MAP function enables mapping a set of values into a LAMBDA function. Inside the LAMBDA function, a formula can be applied iteratively to each mapped value. The LAMBDA declares one (arbitrary) name (variable) for each set of mapped values which the formula uses in order to refer to the current mapped value.

MAP 函数使一组值映射到LAMBDA函数中。在LAMBDA函数内,可以迭代地对每个映射值应用公式。LAMBDA声明一个(任意的)名称(变量)用于每组映射值,公式使用这些名称来引用当前映射值。

So, looking at the initial MAP and LAMBDA parts of the formula:

因此,看一下公式的初始部分MAPLAMBDA

Now to build the 3 column array:

  • The first row is set as { "Cashflow", "Year", "Outflow" }
  • Each row has s in the "Cashflow" column: { 1; 2; 3; 4; 5 }
  • the "Start date" start, offset by s-1 years, goes in column 2
  • start is offset s-1 years instead of s years because start is always the first date in the table, therefore the first calculation must be start+0yr not start+1yr: { start+0yr; start+1yr; start+2yr; start+3yr; start+4yr }
  • lastly, the negative "Premium amount" (-prem) is placed in column 3, but only if the date in column 2 falls within the "Prem. pmt term" (pmt), otherwise a 0 is placed instead

现在来构建三列数组:

  • 第一行设置为 { "Cashflow", "Year", "Outflow" }
  • 每一行在**“Cashflow”**列中都有s:{ 1; 2; 3; 4; 5 }
  • “开始日期” start,通过s-1年偏移,放在第2列
  • start被偏移s-1年而不是s年,因为start始终是表格中的第一个日期,因此第一次计算必须是start+0年而不是`
英文:

>This process of manually entering the dates as per the cashflow is quite tedious and I am sure there is a better way to manage this.

Example: Policy XXXX1245S

  1. "Year" column is a range of dates.
    • First date is the "Start Date" in Cashflow sheet'!J5
    • Dates increment by 1 year
    • Final date is x years after the "Start Date" where x = "Policy term" 'Cashflow sheet'!J9
  2. Outflow is a number based on the "Premium amount" 'Cashflow sheet'!J3
    • Outflow is included on the "Start Date" and for y more years, where y = "Prem. pmt term" 'Cashflow sheet'!J8

Named Ranges

To make the formula easier to follow I've used named ranges

Name Reference                              Notes                                                                                                   
pmt 'Cashflow sheet'!J8 Prem. pmt term
pol 'Cashflow sheet'!J9 Policy term
start 'Cashflow sheet'!J5 Start date
prem 'Cashflow sheet'!J3 Premium amount

Formula

The following formula will dynamically create the first three columns <sup><img src="https://i.stack.imgur.com/o2bPu.png" width="200" /></sup> with as many rows as is required and properly populated. If the logic for the "Inflow" column was better understood, it too could be populated in the same formula. Frankly the entire table including the information at the top could probably be populated from one formula based solely on the "Policy No." if all the required data is stored in the Master List sheet.

={ &quot;Cashflow&quot;, &quot;Year&quot;, &quot;Outflow&quot;;
    MAP(SEQUENCE(pol+1), LAMBDA(s, 
        { s,(EDATE(start, (s-1)*12)), IF(s&lt;=pmt,-prem,0) })) }

<img src="https://i.stack.imgur.com/w0BOJ.png" width="600" />

  1. A LAMBDA function is used to create the array.
  2. A SEQUENCE of numbers representing policy term years is generated and MAP into the LAMBDA function which applies the formula once for each value in the SEQUENCE
  3. "Cashflow" column is equal to the position in the SEQUENCE, so the mapped value s is placed in the first column.
  4. In the "Year" column EDATE is used to offset the "Start Date" by the number of years equal to the mapped value (s-1)*12. The years are multiplied by 12 because EDATE offsets in months.
  5. Finally, the "Outflow" column is populated with the "Premium Amount" if the mapped value s is <= to the "Prem. pmt term". If not, the "Outflow" column is set to zero.

&nbsp;


&nbsp;

Additional Info

The SEQUENCE function creates an array of specified dimensions, populated with a number sequence starting at a specified value, and incrementing (stepping) by another specified value. The only required value, however, is rows (height).

Syntax: SEQUENCE(rows, [columns], [start], [step])

=SEQUENCE(5)       // rows=5, cols=1, start=1, step=1
={1;2;3;4;5}           

=SEQUENCE(2,4)     // rows=2, cols=4, start=1, step=1
={1,2,3,4;5,6,7,8}

The MAP function enables mapping a set of values into a LAMBDA function. Inside the LAMBDA function, a formula can be applied iteratively to each mapped value. The LAMBDA declares one (arbitrary) name (variable) for each set of mapped values which the formula uses in order to refer to the current mapped value.

# one set of values mapped
=MAP(values, LAMBDA(name, formula))

# two sets of values mapped
=MAP(values1, values2, LAMBDA(name1, name2, formula))

So, looking at the initial MAP and LAMBDA parts of the formula:

# - &#39;pol+1&#39; is sequenced instead of &#39;pol&#39; because
#    it was noted that the date list was always 1 
#    row longer than the number in &quot;Policy term&quot; 
# - &#39;s+0&#39; is the &#39;formula&#39; in this example just to 
#    avoid confusing the &#39;name&#39; and the &#39;formula&#39;
# - &#39;pol&#39;=4 in this example
# - &#39;MAP(values, LAMBDA(name, formula))&#39;

=MAP(SEQUENCE(pol+1), LAMBDA(s, s+0) 
={ 1; 2; 3; 4; 5 }

Now to build the 3 column array:

  • The first row is set as { &quot;Cashflow&quot;, &quot;Year&quot;, &quot;Outflow&quot; }
  • Each row has s in the "Cashflow" column:
    { 1; 2; 3; 4; 5 }
  • the "Start date" start, offset by s-1 years, goes in column 2
  • start is offset s-1 years instead of s years because start is always the first date in the table, therefore the first calculation must be start+0yr not start+1yr:
    { start+0yr; start+1yr; start+2yr; start+3yr; start+4yr }
  • lastly, the negative "Premium amount" (-prem) is placed in column 3, but only if the date in column 2 falls within the "Prem. pmt term" (pmt), otherwise a 0 is placed instead
# - Instead of &#39;start+(s-1)years&#39;, as EDATE
#   offsets in months (not years), the calculation
#   is adapted by multiplying by 12:
#   &#39;(EDATE(start, (s-1)*12)&#39;
# - &#39;pol&#39;=4, &#39;start&#39;=2/28/2021,
#   &#39;prem&#39;=199, `pmt`=3   

={ &quot;Cashflow&quot;, &quot;Year&quot;, &quot;Outflow&quot;;
    MAP(SEQUENCE(pol+1), LAMBDA(s, 
      { s,(EDATE(start, (s-1)*12)),
        IF(s&lt;=pmt,-prem,0)         }
    ))
 }

= { &quot;Cashflow&quot;, &quot;Year&quot;, &quot;Outflow&quot;;
    1, 2/28/2021, -199;
    2, 2/28/2022, -199;
    3, 2/28/2023, -199;
    4, 2/28/2024, 0;
    5, 2/28/2025, 0 }

huangapple
  • 本文由 发表于 2023年3月3日 19:39:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/75626619.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定