Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I would like to know if there is a way to display dynamically last 12 months data based on Year/Quarter/Month Selection
Tried Many ways but couldnt achieve with Date Hirearchy filter.
If user selects 2021 Q1 ..It should display last 12 months data with axis 2021.01 , 2021.02 , 2021.03 , 2020.12 , 2020.11 , 2020.10 etc
if user selects 2021 March ..It should display march data along with last 12 months data.
Any help would be appreciated 🙂
Solved! Go to Solution.
Hi,
There are multiple ways to do this. One of the more straightforward ways is to make a copy of your calendar table:
Now create measure with following dax:
The visual uses calendar[Date] and slicer calendar_for_visual[date]
Proud to be a Super User!
It was useful for me.
I thought about sharing this tutorial for anyone who would have the same issue but with other visuals where you don't want to activate the relationships between the two calendar tables in every single mesures and keep your dates fields from your main calendar table.
Show last 6 months based on user single slicer selection from SQLBI
Hi @ValtteriN
I followed the same process as you said but the visual displaying whatever month i selected instead of last 12 months, not sure where i missed .
Hi,
Is your relationship M:1 and inactive with filter direction "single" like in my example? Another possible problem might be with the slicer visual. Are you using 'Calendar for visual' table as the slicer? At a glance your DAX seems to follow the same logic so the problem is with visual or relationships.
Proud to be a Super User!
Hi,
There are multiple ways to do this. One of the more straightforward ways is to make a copy of your calendar table:
Now create measure with following dax:
The visual uses calendar[Date] and slicer calendar_for_visual[date]
Proud to be a Super User!
Hi,
Thank you for your reply. Actually I want my trend chart shows last 12 months as default chart view but if any Date filter is selected then the chart/measure should "reset" this 12 months period from the chart view and behave like a standard view that reacts on the slicer selection i.e if user selects "January" it should show January only and not January with previous 12 months...Hope this explanaition is clear now.
This very interesting solution. However I would like to modify it a bit and maybe it will be easy for you support me. I follow you guidance and everything works perfect but I would like my Last12Month works only when no "Date" filter/slicer is applied. If user select on the slicer specific month or year ect. then the measure should show exact selected period (with no additional previous 12 months data). Is there a way that we can doi it?
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
27 | |
10 | |
10 | |
9 | |
6 |