Forum Discussion

shippen70's avatar
shippen70
Helper I
6 years ago

Direct Query Calculate LastDate issue

I am creating a visual for a Direct Query.  I need to return the LastDate from my Date Dimension table (Rolling Calendar) and pass that into my CALCULATE Function to sum the TotalDrawers for that date.  I keep getting a locking error.  When I check it in DAXStudio it indicated there is an issue with LASTDATE.  Seems that this has to do with the LASTDATE being used in a CALCULATE function on a Direct Query.  Any thoughts on how to resolve the issue?

 

 

 
 

 

 

WTDDrawers =
VAR SelectDate =
LASTDATE( 'Rolling Calendar'[Calendar Date] )
VAR DayNumberOfWeek =
WEEKDAY ( LASTDATE ( 'Rolling Calendar'[Calendar Date] ), 1 )
//VAR TestFirstDate = DATEADD ( SelectDate, ( -1 * DayNumberOfWeek ) + 1, DAY )
RETURN
CALCULATE (
SUM ( _AE1WeekComp[TotalDrawers] ),
DATESBETWEEN (
'Rolling Calendar'[Calendar Date],
DATEADD ( SelectDate, ( -1 * DayNumberOfWeek ), DAY ),
SelectDate
)
)

5 Replies