cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
Super User IV
Super User IV

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

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

 


______________


Has this post solved your problem? Please mark it as a 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.


I work as a trainer and consultant for Microsoft 365, specialising in Power BI and Power Query. 


excelwithallison.com

Highlighted
Memorable Member
Memorable Member

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

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.

Highlighted
Frequent Visitor

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

This is not working for me

Highlighted
Super User IV
Super User IV

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

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))

 


______________


Has this post solved your problem? Please mark it as a 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.


I work as a trainer and consultant for Microsoft 365, specialising in Power BI and Power Query. 


excelwithallison.com

Helpful resources

Announcements

August Community Highlights

Check out a full recap of the month!

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power BI

Join us for an in-depth look at the new Power BI features and capabilities at the free Microsoft Business Applications Launch Event.