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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
NOVICE02
Helper III
Helper III

Marking date if it falls in the last 6 months - Only have partial answer

Hi there,

 

I have a simple problem and I can't seem to figure it out. I have Year to date information that i am displaying but for a few visuals I only want to show the data if it falls in the 6 months prior to the previous month.

 

i.e. In september, i only want to show data between February and July. And so on... 


I understand that I will need to create a measure to mark all the dates that fall in this timeline and this is what I am did

 

Report_Month = IF(and(month(Date_Calendar[Date]) <= MONTH(today())-2,Month(Date_Calendar[Date]) >= MONTH(today())-7), 1,0)
 
But , when I check the data, it will fail once dates start overlapping years... Is there a way to modify this ? or is a completely different measure. Appreciate any help
1 ACCEPTED SOLUTION

Thanks Amit, I actually found a solution:

 

Report_Month =
var monthDiff = (YEAR(TODAY()) - YEAR(Date_Calendar[Date]))*12 + MONTH(TODAY()) - MONTH(Date_Calendar[Date])
return IF(monthDiff <= 1,"Last 2 Month",
IF(monthDiff < 8, "Last 6 month",
IF(monthDiff <10,"Last 9 month",
"more than a year")))
 
But I will use yours as well for reference. Appreciate it

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@NOVICE02 , Try a measure like with help from date table

 

Rolling 6 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ], eomonth(MAX('Date'[Date ]), -1) ,-6,MONTH))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks Amit, I actually found a solution:

 

Report_Month =
var monthDiff = (YEAR(TODAY()) - YEAR(Date_Calendar[Date]))*12 + MONTH(TODAY()) - MONTH(Date_Calendar[Date])
return IF(monthDiff <= 1,"Last 2 Month",
IF(monthDiff < 8, "Last 6 month",
IF(monthDiff <10,"Last 9 month",
"more than a year")))
 
But I will use yours as well for reference. Appreciate it

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.