Forum Discussion
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
- itchyeyeballsImpactful 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
- Patrick_KnobelNew Member
Thanks for your answer, but the result is the same as I totally omit the all-Filter.
The problem is actually this one:
I want to produce a visual with a moving annual total for each month. So, in January I want to see on the visuale a stacked column with the different productsubcategories for the range from Dec 14 - Dec 15, as well as from Nov 14 - Nov 15, and so on. Is there any possibility to do a visual like that?
Thanks for you help.
- itchyeyeballsImpactful Individual
You could use the year to date function rather than calculate - https://msdn.microsoft.com/en-us/library/ee634400.aspx
you should just need one new column in your date table which has the end of the month date to pass to the function.You can calculate that using