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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors