Forum Discussion
Problem with Moving Annual Total
Patrick_Knobel, thanks for including the image of your desired end result. It is very helpful. It's clear now what you need.
Here's my reproduction of your visual:
A few things to note. The visual is a stacked column. The axis labels are simply my months. The measure is a simple SUM( FactStupid[Amount] ). The legend is my DimProduct[Model]. The only special sauce in the whole setup is a visual-level filter on my field DimDate[Rolling 12M] = True.
It looks like you've got fields in your date dimension already that can help fill this role, if not, it's trivial. Here's my DAX for the column:
Rolling 12M = VAR CurrentMonth = LOOKUPVALUE( DimDate[MonthIndex] ,DimDate[Date] ,TODAY() ) RETURN DimDate[MonthIndex] >= CurrentMonth - 11 && DimDate[MonthIndex] <= CurrentMonth
Where [MonthIndex] is an incrementing counter that indicates the number of months that have passed since the beginning of my calendar. In Power Query, here's how I create [MonthIndex] (as a custom added column):
= let Mult = [Year] - List.Min( MonthNumber[Year] ) ,Index = 12 * Mult + [MonthNumber] in Index
'MonthNumber[Year]' is the reference to the [Year] column in the previous step in Power Query. MonthNumber, in that context, refers to the name of the previous step.
This is actually the problem that I am looking to solve and the function which has made me keep searching for a simple charting tool to work with QuickBooks Online. I am pretty new to PowerBI and have no idea where I am supposed to write the formulas you are describing. It would be great if one of you could point me in the right direction.
Thanks in advance
Huw