Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
mthukara
Frequent Visitor

Top 12 months in Visual based on selection from page level filter

Dear All,

 

I have date column as part of the Page filter and not slicers

Users can select a single month in the filter pane; for example 2020-03

I have a bar chart visual which should display last 12 months from the selected Month ( In this case April'19 to Mar'20)

Because of the page level filter bar chart was showing only March 2020

Used ALL in the filter then i can get all the months in the database ( In this case Jan'19 to May'20)

dax - C_EmpCount_Trend = CALCULATE(SUM('emp'[EMPLOYEE_COUNT]),ALL('emp'[SNAP_DT]))
above dax is giving all the months from database but i need to show only last 12 months based on the selection
 
Kindly help how to apply the flast 12 month filter in to this dax
 
Thansk!
 
 

 

 

 

4 REPLIES 4
AllisonKennedy
Super User
Super User

You could try using a DATESBETWEEN or DATESINPERIOD with the MIN(DimDate[Date])

I think DATESINPERIOD would work better for your purpose:
DATESINPERIOD(DimDate[Date], MIN(DimDate[Date]), -12, Month)
https://docs.microsoft.com/en-us/dax/datesinperiod-function-dax

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

As suggested, i tried the same. But it is not working.

I am also having the same issue. Can you please suggest if it is working for you.

This is not working for me

Can you provide a sample report? You might need to use a variable to determine the min date, then use ALL() with the DATESINPERIOD:

C_EmpCount_Trend =
VAR _MinDate = MIN(DimDate[Date])
RETURN
CALCULATE(SUM('emp'[EMPLOYEE_COUNT]),ALL('emp'[SNAP_DT]), DATESINPERIOD(ALL(DimDate[Date]), _MinDate, -12, Month))

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.