Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowGet inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.
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.
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
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.
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
Based on the posts in this thread it is unclear if you need a [YTD Last Year] or a [Rolling Year].
Here's both with built in time intelligence (normal date dimension requirements here):
SumAmt = SUM( FactStupid[Amount] ) RollingYear = CALCULATE( [SumAmt] ,DATESINPERIOD( DimDate[Date] ,MAX( DimDate[Date] ) ,-1 ,YEAR ) ) YTD = TOTALYTD( [SumAmt] ,DimDate[Date] ) YTD Last Year = CALCULATE( [YTD] ,SAMEPERIODLASTYEAR( DimDate[Date] ) )
These have the benefit of working from any reference year, rather than only working only for last year based on today's date.
You can set a filter for CurrentYear = True on the page or report and these will function appropriately. Or you can set a filter for CurrentYTD = True
Im looking after the Rolling Year.
In my Datetable I've created columns which yield in TRUE if a certain condition is fullfilled. This columns are dynamic, since I do not want to change the filter context each time when refreshed. For example the column for last year is calculated as follows:
LastYear = if(Year(DATEADD('Calendar'(Date);12;MONTH))=Year(Today());"TRUE")
Now I want to do a visual with lines or stocked columns for each product subcategorie, which display as well the rolling year started in the month before. In the datetable this is created by:
LYM-1 = if(Year(DATEADD('Calendar'(Date);13;MONTH))=Year(Today());"TRUE")
Based on this columnes I can achieve the value for the period in question. The measures look like:
LYSales = Calculate(Sum(Sales(SalesAC));Filter(all('Calendar');'Calendar'(LastYear)="TRUE"))
LYM-1Sales = Calculate(Sum(Sales(SalesAC);Filter(all('Calendar');'Calendar'(LYM-1)="TRUE"))
But I'm not able to visualize this in a stacked column or line chart, where each column, respective each datapoint on the line represents a rolling year(eg. LYSales and LYM-1Sales). Do you have any ideas how to solve this problem?
Thanks for your help.
I've now got no idea where your problem lies. Is it in the measure logic, or in getting the appropriate subset of values to display on the axis?
Hello togehther,
in the meantime I could solve the issue. The problem was, that I've created for each period a measure for the moving annual total and wanted to display it in a visual with a time axis and as legend the subcategories. This has not worked out, so I've built a measure which calculates the moving annual total for each period based on the imposed conditions on the period under question:
Here you find my measure, which looks a bit complicated, but basically it's just a 11 times nested if condition:
With this I was able to creat the visual I wanted. The only thing, I'm not fully convinced is the timing. Basically the start of the visual timeline is given by the starting date of the first period to sum up, which leads to the point, that the time axis is moved 1 year backwards. Here you find the visual:
If you have an idea to get to this result in an easier way I would appreciate your comments and ideas.
@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
I want to find the Moving Annual Total(MAT). But in my case ecah months are separate column.How to find it
I want to find Moving annual total . But in my case each months are separete column.How to find it
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
84 | |
70 | |
66 | |
50 | |
31 |
User | Count |
---|---|
116 | |
99 | |
75 | |
65 | |
40 |