@Neville,
I think if you used DATESBETWEEN (like @JBright mentioned) combined with using SAMEPERIODLASTYEAR and FIRSTDATE/LASTDATE you will get the output you are expecting, well hopefully
Previous Working Days =
/*Variables to define what the previous start and end dates are*/
VAR _PrevStart = SAMEPERIODLASTYEAR( FIRSTDATE( 'Date'[Date])) --Using the Current Filter context, goes back one year from the start
VAR _PrevEnd = SAMEPERIODLASTYEAR( LASTDATE('Date'[Date])) --Using the Current Filter context, goes back one year from the end
/* Number of days between the start and the end, used to check if our calendar has dates that go back that far*/
VAR _StartEnd = INT( _PrevEnd - _PrevStart )
RETURN
IF(
NOT ISBLANK(_StartEnd), --Checks to see if there are days between the start and end. The NOT turns True into False and False into True
CALCULATE(
[Working Days] --Previous defined measure that has the logic to count the # of working days
,DATESBETWEEN( 'Date'[Date], _PrevStart,_PrevEnd) --Use DATESBETWEEN to modify the current filter context. Use the start/end from the above variables
)
)
in your data set we had complete days for April and May of FY21, which we would then want the full month of working days previously:
I believe the issue you were running into was that in June FY21, there was only data from 6-1 to 6-8 but you were getting the full amount of June FY20 working days. Using the _PrevStart and _PrevEnd variables will account for that, and only give you the total number of working days from the start and end of the current filter context: