Forum Discussion
Compute customer life time value by payment period
Hi,
I have built a model to calculate Life Time Value based on the months in which contracts are valid, but need to change the logic to compute the LTV by payment period or daily LTV.
This what I need to get as a result (this or the same set up on a daily basis, just not restricted to the calendar month structure):
I was thinking I could generate a list to get the list of days covered by the contract (instead of the list of months) in Power Query, then make a join on the date column with my date table. But I don't find a function similar to Date.StartOfMonth that would replace the month list generation:
List.Select(
List.Dates(
Date.StartOfMonth([Vertragsbeginn]),
Number.From([Vertragsende]- [Vertragsbeginn]),
#duration(1, 0, 0, 0)),
each Date.Day(_) = 1)
Basically I just need to generate the list of days based on the contract start date and taking into account the number of months in which the contract is valid.
I can't get my head around as how to get there in Power Query. How can I rewrite this or approach this in a different way?
Any help will be greatly appreciated 🙂 🙂
- Anonymous2 years ago
Hi Berl21 ,
Based on my testing, please try the following methods:
1.Create the sample table.
2.Create the new custom column in power query.
3.Drag Enter the following formula.
List.Select(List.Dates([Start Date],Duration.TotalDays([Payment period] - [Start Date]), #duration(1,0,0,0)), each true)4.Expand the list. The result is shown below.
Best Regards,
Wisdom Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
2 Replies
- ryan_mayu
Super User
why the end date of first row is 26th, and for the second row is 28th?
- AnonymousNot applicable
Hi Berl21 ,
Based on my testing, please try the following methods:
1.Create the sample table.
2.Create the new custom column in power query.
3.Drag Enter the following formula.
List.Select(List.Dates([Start Date],Duration.TotalDays([Payment period] - [Start Date]), #duration(1,0,0,0)), each true)4.Expand the list. The result is shown below.
Best Regards,
Wisdom Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.