Forum Discussion
Distribute pre-payments
I have the following table with payments. These are for pre-payments for a set of terms.
| InvoiceNo | Invoice Date | Amount | Terms |
| N0001 | 2-7-2020 | 6000 | 6 |
| N0002 | 5-8-2020 | 1500 | 3 |
| N0003 | 3-4-2020 | 7300 | 4 |
| N0004 | 2-1-2020 | 60 | 1 |
I want to report the turnover distributed over the months of the terms. So need a table like the below:
| InvoiceNo | Turnover Date | Amount |
| N0001 | 2-7-2020 | 1000 |
| N0001 | 2-8-2020 | 1000 |
| N0001 | 2-9-2020 | 1000 |
| N0001 | 2-10-2020 | 1000 |
| N0001 | 2-11-2020 | 1000 |
| N0001 | 2-12-2020 | 1000 |
| N0002 | 5-8-2020 | 500 |
| N0002 | 5-9-2020 | 500 |
| N0002 | 5-10-2020 | 500 |
| N0003 | 3-4-2020 | 1825 |
| N0003 | 3-5-2020 | 1825 |
| N0003 | 3-6-2020 | 1825 |
| N0003 | 3-7-2020 | 1825 |
| N0004 | 2-1-2020 | 60 |
I am struggling with a DAX formula to create this table. I am working with GENERATESERIES, but stuck because the no. of terms is not always the same.
Thanks in advance for your help!
Anonymous - Hmm, this seems similar to what you are trying to do:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Periodic-Revenue-Reverse-YTD/m-p/373185#M111
Also, this might help:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Periodic-Billing/m-p/409365#M148
5 Replies
- parry2kSuper User
Anonymous you should do this transformation in Power Query and create this table instead of DAX
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
- Greg_DecklerCommunity Champion
Anonymous - Hmm, this seems similar to what you are trying to do:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Periodic-Revenue-Reverse-YTD/m-p/373185#M111
Also, this might help:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Periodic-Billing/m-p/409365#M148
- AnonymousNot applicable
Hi Greg,
The solution on periodic billing helps me with constructing the solution.
Thanks for your support.Bas
- daxCommunity Support
Hi Anonymous ,
I think you could use M code to achieve this goal.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("RczLDQAhCATQXjib8FW3im3A0H8bC2zUE8y8ZNaCl4gYGghOFBKKd0SVB7z9LpE6Ptu5l+txzYS2fWq5Hbfa57ufI+D+AQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [InvoiceNo = _t, #"Invoice Date" = _t, Amount = _t, Terms = _t]), #"Changed Type1" = Table.TransformColumnTypes(Source,{{"InvoiceNo", type text}, {"Invoice Date", type date}, {"Amount", Int64.Type}, {"Terms", Int64.Type}}), #"Added Custom" = Table.AddColumn(#"Changed Type1", "Custom", each {Number.From([Invoice Date])..Number.From(Date.AddDays([Invoice Date],[Terms]-1))}), #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"), #"Changed Type" = Table.TransformColumnTypes(#"Expanded Custom",{{"Custom", type date}}), #"Added Custom1" = Table.AddColumn(#"Changed Type", "Custom.1", each [Amount]/[Terms]), #"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Invoice Date", "Amount"}), #"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Custom", "date"}, {"Custom.1", "amount"}}) in #"Renamed Columns"Best Regards,
Zoe ZhiIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- AnonymousNot applicable
Hi Zoe,
Thanks for your reply.
Very clever solution - but solution needs some modification for it to be workable for me as the terms are months, whereas your solution generates the terms based on days.Greetings,
Bas