Forum Discussion
Distributing booking value across start and end dates
- Anonymous7 years ago
This can be done with dax, but would have to mix filters and relationships, etc. So if you arent opposed to using Power Query, this can be done pretty easily. I attached the pbix file below, but basically it is doing:
- Find the amount of days between start and end ( you have a column in there already, but wanted to make this work with whatever future data you may have)
- Add a custom column that produces a list of dates beteen that start and end date
List.Dates([Start Date], [Days Between], #duration(1,0,0,0) )
- Divide out the USD amount and the days between from #1 above. Again, you had this in there, but wanted to be sure it would work in the future
- Remove the misc columns we no longer need
- Expand the list of dates. So this will have the average value per day
- Relate the DimDate to this table ( also, be sure to mark the date table as a Date Table in the Data view, also be sure to sort the Month Name by the Month Number column)
Then just a simple sum formula:
Easy Sum = sum( Table1[Avg Per Day] )
And the final table:
Here's the file so you can step through the applied steps ( you can ignore the first couple as I was having trouble with the dates)
- 7 years ago
hi, hallpalmjame
Try this way as below:
Create a new table
Table = FILTER(CROSSJOIN(Bookings,DimDates),Bookings[StartDate]<='DimDates'[Date]&&Bookings[EndDate]>='DimDates'[Date])
Then drag date and DAYUSD from New table
here is pbix file,please try it.
Best Regards,
Lin
Thanks. Tried to get it working from the post, no luck
PBIX attached.
https://1drv.ms/u/s!AhWg2JbSP2spicUvSi5h0UnsI09vAQ
Base data below
| BOOKING NUMBER | Start Date | End Date | Duration | AMOUNT | COMPANY | DAYUSD |
| 2019-03-000003 | 10/03/2019 | 08/04/2019 | 30 | 30,000.00 | RED | 1000 |
| 2019-03-000002 | 10/03/2019 | 30/03/2019 | 21 | 42,000.00 | Blue | 2000 |
| 2019-03-000001 | 07/03/2019 | 30/03/2019 | 24 | 12,000.00 | Orange | 500 |
| 2019-02-000008 | 03/03/2019 | 31/03/2019 | 29 | 5,800.00 | Red | 200 |
Should translate to on the Distributed Sheet
February 81800 USD
April 8000 USD
As only the first order has any days in April, a total of 8 days for 1000 USD a day
Any help appreciated
hi, hallpalmjame
Try this way as below:
Create a new table
Table = FILTER(CROSSJOIN(Bookings,DimDates),Bookings[StartDate]<='DimDates'[Date]&&Bookings[EndDate]>='DimDates'[Date])
Then drag date and DAYUSD from New table
here is pbix file,please try it.
Best Regards,
Lin
- hallpalmjame7 years agoNew Member
Thanks both great job and both solutions work!