Forum Discussion
Adding a +1 inside Date function results in an error but when adding +1 outside works fine, why?
- Anonymous3 years ago
Hi TallPolishAdam ,
I think the final two measures should be correct.
In your first code, you add "- WEEKDAY([Date of Report], 2) + 1" in Date() function. Power BI will check whether year/month/day parts all correct, then return date value. So if day part return Negative numbers, Power BI will return error.
Week of Report = DATE ( YEAR ( [Date of Report] ), MONTH ( [Date of Report] ), DAY ( [Date of Report] ) - WEEKDAY ( [Date of Report], 2 ) + 1 )The final two measures, both add "- WEEKDAY([Date of Report], 2) + 1" outof date, so Power BI will do calculation on [Date of Report] and think "- WEEKDAY([Date of Report], 2) + 1" as days.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Just looking at the code, my guess is, because you are adding 1 to a number then subtracting that you are getting some results like 2022/10/-1