Forum Discussion

Patrick_Knobel's avatar
Patrick_Knobel
New Member
10 years ago

Problem with Moving Annual Total

Hello,

 

I created several Columns in my Date-Table wich indicate dynamically if a date belongs to a certain period. This is important, because I do not want to change the filtering conditions all the time the report has to be refreshed. I have then set up a measure for the moving annual Total in the following way:

 

Cummulated Sales = Calculate(Sum(Sales[SalesAC]);Filter('Calendar';'Calendar'[LastYear]="TRUE"))

 

but this does not cummulate the values. If I change the measure to:

 

Cummulated Sales 2 = Calculate(Sum(Sales[SalesAC]);Filter(all('Calendar');'Calendar'[LastYear]="TRUE"))

 

it does sum up the values correctly for the period in question, but I have the value also for all other dates out of this period.

 

How can I solve this problem? I just want a measure, which allows me to set a dynamic start and end date for the period which needs to be cummulated and is just displayed in this period.

 

Thanks for your anwers.

11 Replies

  • itchyeyeballs's avatar
    itchyeyeballs
    Impactful Individual

    I don't think the ALL should be inside the filter

     

    try something like

     

    Calculate(Sum(Sales[SalesAC]),Filter('Calendar'[LastYear]="TRUE"),all('Calendar'))

     

    It may also be worth looking at the DAX time intelligence fucntions. I have a measure that returns sum for previous year that looks like

     

    Calculate(SUM(Tablename[col]),previousyear('Calendar'[End Date],"August 31"),ALL('Calendar'))

     

    If you want a period other than pervious year there are other functions to define periods dynamically such as datesinperiod or datesbetween - https://msdn.microsoft.com/en-us/library/ee634763.aspx