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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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