Reputation: 2370
I have successfully calculated "WorkDaysPassed - Current Mo". This is a calculated column that counts the number of working days have passed in the month, only for the current month and the value is printed for each date record in the current month. Current month is ending '1/31/2022'.
I need help figuring out how to print this same value on the prior months date records. Prior month is ending '12/31/2021'. The calculated column would be named "WorkDaysPassed - Closing Month". I think the NEXTMONTH()
calculation could do this in in aggregate function.
How to do this in a calculated column? Below is what I have tried to calculate so far.
WorkDaysPassed - Current Mo =
IF( NOT('Calendar'[IsCurrentMonth]), BLANK(),
CALCULATE(
COUNTROWS ( 'Calendar' ),
'Calendar'[Date],
'Calendar'[IsWorkingDay] = TRUE
&& 'Calendar'[Date] <= TODAY ()
&& MONTH('Calendar'[Date]) = MONTH(TODAY())
&& YEAR('Calendar'[Date]) = YEAR(TODAY())
))
WorkDaysPassed - Closing Month =
CALCULATE(SUM('Calendar'[WorkDaysPassed - Current Mo]), ALL('Calendar') )
Upvotes: 0
Views: 795
Reputation: 2370
I was able to get this working by defining a Calculated Measure and the referencing the measure in the Calculated Column.
WorkingDays - MTD Current Mo =
IF( NOT(VALUES('Calendar'[IsCurrentMonth])), BLANK(),
CALCULATE (
COUNTROWS ( 'Calendar' ),
'Calendar'[Date],
'Calendar'[IsWorkingDay] = TRUE
&& 'Calendar'[Date] <= TODAY ()
&& MONTH('Calendar'[Date]) = MONTH(TODAY())
&& YEAR('Calendar'[Date]) = YEAR(TODAY())
))
Working Days MTD - Closing Month =
IF(NOT(HASONEVALUE('Calendar'[Mo-Yr])),BLANK(),
CALCULATE (
[WorkingDays - MTD Current Mo],
NEXTMONTH ( 'Calendar'[Date] )
))
Upvotes: 0