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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

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: 

JeroenR_0-1640181964561.png

 

 

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: https://www.sqlbi.com/articles/show-previous-6-months-of-data-from-single-slicer-selection/

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.

2 REPLIES 2
negi007
Community Champion
Community Champion

@Anonymous 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

Anonymous
Not applicable

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 (
AND (
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

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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