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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Helper V
Helper V

Show previous 6 months IF is in selected (month) year

Hi all,


I have a slicer on my report where the Month can be selected within a year. The slicers is as follow: 




I am also using the calculation of the SQLBI page where you can display the last 6 months up until the selected month. See following link:

This is all working fine and perfect but I want to change 1 thing regarding this DAX calculation. Can I change this that the last 6 months will be displayed IF it is in the selected year of the selected month. So that means that if a user has selected April 2021, it will only display the months March, Feb and Jan.

Community Champion
Community Champion

@JeroenR can you share your data in text format which can be copied. 

Did I answer your question? Mark my post as a solution!
Appreciate your Kudos

Proud to be a Super User!

Follow me on linkedin

Hi @negi007 , thanks for the reply. 


My date table looks as follow:

DateYearMonth NumMonth NameMonth YearMonth Year OrderCurrent Month
6/1/202120211JanJan 2021202101Previous Month
20/6/202120216JunJun 2021202106Previous Month
15/12/2021202112DecDec 2021202112Current Month


Current Month is calculated as follow:

Current Month =
IF (
YEAR ( 'Date'[Date] ) = YEAR ( NOW () - 1 ),
MONTH ( 'Date'[Date] ) = MONTH ( NOW () - 1 )
"Current Month",
"Previous Months"
Fact table has just a regular date column which is connected with a one to many relationship with my date table. 

Please let me know if you need further information.

Helpful resources

July 2024 Power BI Update

Power BI Monthly Update - July 2024

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

July Newsletter

Fabric Community Update - July 2024

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