Forum Discussion
Number of Days Calculation
- Anonymous5 years ago
Hi Matt_Mohawk ,
Please try to update the formula of your calculated column [# of days] as below:
# of Days = VAR _days = CALCULATE ( SUM ( 'Date'[Workday Not Holiday] ), DATESBETWEEN ( 'Date'[Date], MJS_PRICE_PW[DATE IN], MJS_PRICE_PW[DATE OUT] ) ) RETURN IF ( ISBLANK ( MJS_PRICE_PW[DATE OUT] ), BLANK (), IF ( MJS_PRICE_PW[DATE IN] = MJS_PRICE_PW[DATE OUT], 1, _days - IF ( NOT ( WEEKDAY ( MJS_PRICE_PW[DATE IN], 1 ) IN { 1, 7 } ), 1, 0 ) ) )Best Regards
amitchandak thank you for that formula. I am getting the error, "The start date in Calendar function can not be later than the end date."
I am working with some projects that do not have a "DATE OUT" entered yet. Could this be the cause of that problem? That is the main reason why I had the VAR DATEOUTBLANK in my formula before.
- amitchandak5 years ago
Super User
Matt_Mohawk , add an if on top of it and check if it works. or share small sample with expected output
- Matt_Mohawk5 years ago
Helper II
Below is an example of what I am needing. The areas marked in red show that right now it is counting as 2 days, this is actually supposed to be 1 day because we do not count the day that it comes into us. The green area is the area that I want the formula to ignore because if a project comes in and goes out on the same day, it needs to be counted as 1 day. Hope this makes sense.
- Anonymous5 years agoNot applicable
Hi Matt_Mohawk ,
Please try to update the formula of your calculated column [# of days] as below:
# of Days = VAR _days = CALCULATE ( SUM ( 'Date'[Workday Not Holiday] ), DATESBETWEEN ( 'Date'[Date], MJS_PRICE_PW[DATE IN], MJS_PRICE_PW[DATE OUT] ) ) RETURN IF ( ISBLANK ( MJS_PRICE_PW[DATE OUT] ), BLANK (), IF ( MJS_PRICE_PW[DATE IN] = MJS_PRICE_PW[DATE OUT], 1, _days - IF ( NOT ( WEEKDAY ( MJS_PRICE_PW[DATE IN], 1 ) IN { 1, 7 } ), 1, 0 ) ) )Best Regards