Forum Discussion
DatesYTD Equivalent to Use with Direct Query
- 8 years ago
Hi DAX0110,
I am glad I asked, because I would not have come up with this. You are a genius! The only change that I had to make was to add MAX and correct my poor spelling of 'Calendar'
Cummulative Amount (by Year) =
VAR joinDate = MAX( 'Calendar'[SnapshotDate] )
VAR joinYear = YEAR(MAX('Calendar'[SnapshotDate]) )
RETURN CALCULATE(
SUM('Product'[Amount])
, FILTER(
ALL( Calendar )
, YEAR(Calendar[SnapshotDate]) = joinYear
&& Calendar[SnapshotDate] <= joinDate
)
, ALLEXCEPT( 'Product'
,'Product'[ResultsDescription]
,'Product'[Member]
,Branches[Division]
,Branches[Branch]
)
)
Hi MB2, please try the following to see if it works for you as a replacement for DATESYTD in DirectQuery mode:
**bleep**. Amount (by Year) =
VAR joinDate = MAX( 'Product'[JoinDate] )
VAR joinYear = YEAR( joinDate )
RETURN CALCULATE(
SUM('Product'[Amount])
, FILTER(
ALL( Calender )
, YEAR(Calender[SnapshotDate]) = joinYear
&& Calender[SnapshotDate] <= joinDate
)
, ALLEXCEPT( 'Product'
,'Product'[ResultsDescription]
,'Product'[Member]
,Branches[Division]
,Branches[Branch]
)
)
// you'd need to make some mods to this formula:
// replace 'Product'[JoinDate] with the actual date column used in the relationship with Calendar
Hi DAX0110,
I am glad I asked, because I would not have come up with this. You are a genius! The only change that I had to make was to add MAX and correct my poor spelling of 'Calendar'
Cummulative Amount (by Year) =
VAR joinDate = MAX( 'Calendar'[SnapshotDate] )
VAR joinYear = YEAR(MAX('Calendar'[SnapshotDate]) )
RETURN CALCULATE(
SUM('Product'[Amount])
, FILTER(
ALL( Calendar )
, YEAR(Calendar[SnapshotDate]) = joinYear
&& Calendar[SnapshotDate] <= joinDate
)
, ALLEXCEPT( 'Product'
,'Product'[ResultsDescription]
,'Product'[Member]
,Branches[Division]
,Branches[Branch]
)
)