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
When I insert your new formula, I get an error:
Any idea how to fix this?
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
- weesgaard9 years agoFrequent Visitor
Hi Angelia
That solved the issue, but now I get a new error:
The startdate can´t be after the end-date when using datediff. - any idea how to solve this?
Thanks :)
- v-huizhn-msft9 years ago
Microsoft Employee
Hi weesgaard,
Please debug the error based on the message. Please review the usage of DATEDIFF, startdate must be smaller than enddate, please check DATE(2017;1;1) and Lejer[Uddate], which is bigger.
Best Regards,
Angelia