Forum Discussion
Splitting Values between months of two dates
- 9 years ago
To achieve it, you need to create a calendar table and crossjoin your original table and this calendar table.
In your original table, create a column use the DAX below.
CostPerMonth = Table1[Cost]/(DATEDIFF(Table1[StartdDate],Table1[EndDate],MONTH)+1)Create a calendar table
Calendar = FILTER(CALENDAR("2016-01-01","2017-12-31"),DAY([Date])=1)Crossjoin those two tables.
Table = FILTER(CROSSJOIN(Table1,'Calendar'),'Calendar'[Date]>=Table1[StartdDate]&&'Calendar'[Date]<=Table1[EndDate].[Date])And then you can show your expected result by using a martix visual.
Regards,
Charlie Liao
To achieve it, you need to create a calendar table and crossjoin your original table and this calendar table.
In your original table, create a column use the DAX below.
CostPerMonth = Table1[Cost]/(DATEDIFF(Table1[StartdDate],Table1[EndDate],MONTH)+1)
Create a calendar table
Calendar = FILTER(CALENDAR("2016-01-01","2017-12-31"),DAY([Date])=1)
Crossjoin those two tables.
Table = FILTER(CROSSJOIN(Table1,'Calendar'),'Calendar'[Date]>=Table1[StartdDate]&&'Calendar'[Date]<=Table1[EndDate].[Date])
And then you can show your expected result by using a martix visual.
Regards,
Charlie Liao
Hi, the formula was very useful, but what if you have an overlapping date range.
e.g start date is Jan 15, 2019
end date is feb 10, 2019
how would you group them by month. Thanks!