Forum Discussion

MB2's avatar
MB2
Advocate I
8 years ago
Solved

DatesYTD Equivalent to Use with Direct Query

I am looking for an expression that can substitute for the DatesYTD function in DAX. The DatesYTD function is not compatible with DirectQuery as per here, but I need to use DirectQuery as I am dealin...
  • MB2's avatar
    MB2
    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]
            )
        )