Forum Discussion
Calculate days per month based on date interval
- 9 years ago
Hi weesgaard,
As I test, your TG 01,17 returns the error message as follows.
Please create 01,17 using the formula, you will get expected result.01.17 = IF(Lejer[IndDato]<=DATE(2016,12,31),IF(Lejer[IndDato]<DATE(2017,02,1),DATEDIFF(DATE(2017,1,1),Lejer[UdDato],DAY),31),IF(Lejer[UdDato]<DATE(2017,02,1),DATEDIFF(Lejer[IndDato],Lejer[UdDato],DAY),DATEDIFF(Lejer[IndDato],DATE(2017,1,31),DAY)))
Then you can get the 02,17 using the similar formula.
Best Regards,
Angelia
Hi weesgaard,
Could you please share your formula to create column "TG 02.17" for further analysis?
Best Regards,
Angelia
I believe the formular for TG2 should look like this:
TG 02.17 = IF(AND(Lejer[UdDato]>DATE(2017;01;31);Lejer[IndDato]<DATE(2017;03;1));CALCULATE(SUM(Lejer[UdDato])-CALCULATE(SUM(Lejer[IndDato])))+IF(Lejer[IndDato]<DATE(2017;02;01);CALCULATE(SUM(Lejer[IndDato])-DATE(2017;02;01)))-IF(Lejer[UdDato]>DATE(2017;02;28);CALCULATE(SUM(Lejer[UdDato])-DATE(2017;03;1))))
- v-huizhn-msft9 years ago
Microsoft Employee
Hi weesgaard,
As I test, your TG 01,17 returns the error message as follows.
Please create 01,17 using the formula, you will get expected result.01.17 = IF(Lejer[IndDato]<=DATE(2016,12,31),IF(Lejer[IndDato]<DATE(2017,02,1),DATEDIFF(DATE(2017,1,1),Lejer[UdDato],DAY),31),IF(Lejer[UdDato]<DATE(2017,02,1),DATEDIFF(Lejer[IndDato],Lejer[UdDato],DAY),DATEDIFF(Lejer[IndDato],DATE(2017,1,31),DAY)))
Then you can get the 02,17 using the similar formula.
Best Regards,
Angelia- weesgaard9 years agoFrequent Visitor
When I insert your new formula, I get an error:
Any idea how to fix this?
- v-huizhn-msft9 years ago
Microsoft Employee
Hi weesgaard,
Please replace the DATE(2016,12,31) to DATE(2016;12;31), you should use the delimiter ";" rather than "," in your power BI desktop.
Best Regards,
Angelia