Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.
Hello,
I'm looking to improve the reporting and user experience in my organization through Power BI. Part of this process is to replicate one of our manual Excel based reports in the Power BI environment with the goal of adding additional functionality such as drill down capabilities as a demonstration of whats possible.
I'd like assistance creating a graph that will show me trailing 12 month sales over a 3 year look back period. I would like the visual to automatically update the display to show the most recent year of data in my fact table and display an additional 2 full years prior to that (i.e. max year in my table is 2022) so I would like the trailing twelve months to display from January 1, 2019 through current date in 2022. I have many years of data in my table so the January 1, 2019 displayed start date in my graph should already be the calculated trailing twelve months from January 2nd 2018. Ideally, it like to handle this in DAX and not have to select values from a visual filter.
Below is the code I was able to work through mostly as a proof to myself that trailing twelve months is possible but its only a starting point as I work my way through this learning experience. I appreciate the assistance.
Solved! Go to Solution.
Hi,
See if my solution here helps - Flex a Pivot Table to show data for x months ended a certain user defined month.
Hi,
See if my solution here helps - Flex a Pivot Table to show data for x months ended a certain user defined month.
@Henault , Try like
Rolling 12 Sales =
var _max = maxx(allselcted(date),date[date]) // or today()
var _min = date(year(_max), month(_max)-12,1)
return
CALCULATE(SUM(Sales[Sales Amount]),filter(date, date[date] <=_max && date[date] >=_min))
or
Rolling 12 Sales =
var _max = maxx(allselcted(date),date[date]) // or today()
var _min = date(year(_max), month(_max)-12,day(_max))
return
CALCULATE(SUM(Sales[Sales Amount]),filter(date, date[date] <=_max && date[date] >=_min))
or
Rolling 12 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-12,MONTH))
Check out the November 2023 Power BI update to learn about new features.
Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.
Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!