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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch 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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.