I have a table with contract data between the years 2013 and 2019. Each of the rows corresponds to a contract, with different columns listing its features, among which Date Start, Date End and Total Volume of Funds. All dates are dd/mm/yyyy.
My organisation wants to analyze how much available funding it has for any given year, based on how much funding from each of the contracts falls within that year. The calculation we want is not a really sophisticated one, so we are happy allocating the budget lineally, as if the funds would have to be spent regardless of the type of day (working/non-working). I understand I need to calculate the duration of each contract in days (done), then divide the total funding by the days to find the amount per day (done), to get the unit that I could then multiply by the number of days a given contract has in one year.
I am having trouble finding solutions for the last step online: calculating how many days each contract has within each specific year, so I can multiply that figure by the daily funds I have in a calculated column. This is something I could probably do in Python, but my knowledge of DAX is even more limited and I cannot seem to figure out how to solve this.
Below, a mock-up of the table I am working with (columns "Contract Code" to "ContractEnd"), and an example of how I want my output to look like (columns "Budget2015" to "Budget2018"). Note the table should adjust the available funds for each year according to each contract´s start- and end dates:
Hi, I'm not proud of this solution, there should be more sophisticated ones. But I guess you can create a calculated column per year with:
Budget 2015 =
VAR TotalDays = Table1[ContractEnd]-Table1[ContractStart]
VAR StartDate = DATE(2015;01;01)
VAR EndDate = Date(2015;12;31)
VAR ActualStartDate = IF(Table1[ContractStart]<StartDate;StartDate;Table1[ContractStart])
VAR ActualEndDate = IF(Table1[ContractEnd]>EndDate;EndDate;Table1[ContractEnd])
Note that 2016 is i leap year.
Then you get (I guess there's a typo in your last row):