Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Current week date filter applied to all days between two dates

I'm trying to add a slicer for filtering down PTO requests that fall within the current week, but I can't get it to filter correctly.    My data set is pretty simple and includes a start and end da...
  • TheoC's avatar
    2 years ago

    Hi @SHenderosn 

     

    You should be able to achieve this by adding a calculated column in your PTO table that checks whether the specific record is in the current week or not. This column can then be used as a Slicer to filter whether a PTO falls within the Current Week. 

     

    Just update the below to your table and column names and it should work well.  You can then add this as a slicer and achieve your desired output. 

     

    PTO_In_Current_Week = 
    
    VAR _start = 
    
    	CALCULATE ( 
    		MIN ( 'DateTable'[Date] ) , 'DateTable'[CurrentWeekOffset] = 0 
    		)
    
    VAR _end = 
    
    	CALCULATE ( 
    		MAX ( 'DateTable'[Date] ) , 'DateTable'[CurrentWeekOffset] = 0 
    		)
    
    RETURN
    
    IF (
        AND (
            'PTOTable'[Start Date] <= _end , 
            'PTOTable'[End Date] >= _start ) ,
        "Current Week" , "Not Current Week"
    	)
    
    )

     

    Hope this works okay!

     

    Theo

  • Anonymous's avatar
    Anonymous
    2 years ago

    This is exactly what I needed, thank you!