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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Top Kudoed Authors