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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Date column last x months

Hello everyone,

 

I have created a calculated column which filters the most recent months, in this particular example the last two months. This filter was working, but only in the year itself. Now we are in the new year, it shows only the month of this year, but it still want the months of 2021. So I want all the dates from 1 November till today (so the 4th of January). 

 

The formula is as follows:

Last 2 months = IF(OR(Month([Date])=Month(Today())-1, MONTH([Date]) =MONTH(TODAY())), "Last 2 months", BLANK())
 
How can this formula be adjusted that is returns also the months in the previous year? 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thank you @amitchandak for your (fast) reply 🙂

The results I got were alle blanks, so I adjusted the formula as follows:

Last 2 months = IF(OR(OR(EOMONTH([Date], 0) =EOMONTH(TODAY(), 0), EOMONTH([Date], 0) = EOMONTH(TODAY(), -1)), EOMONTH([Date], 0) = EOMONTH(TODAY(), -2)), "Laatste 2 maanden", BLANK())
 
This resulted in the desired outcome.

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , better to use EOmonth to deal with months

 

check one of three should work

 

Last 2 months = IF(eomonth([Date],0)=eoMonth(Today(),-3)+1 && [Date] <=TODAY(), "Last 2 months", BLANK())

 

or

Last 2 months = IF(eomonth([Date],0)=eoMonth(Today(),-3)+1 && eomonth([Date],0) <=eomonth(TODAY(),0), "Last 2 months", BLANK())

 

or

 

Last 2 months = IF(eomonth([Date],0)=eoMonth(Today(),-3)+1 && eomonth([Date],0) <=eomonth(TODAY(),-1), "Last 2 months", BLANK())

Anonymous
Not applicable

Thank you @amitchandak for your (fast) reply 🙂

The results I got were alle blanks, so I adjusted the formula as follows:

Last 2 months = IF(OR(OR(EOMONTH([Date], 0) =EOMONTH(TODAY(), 0), EOMONTH([Date], 0) = EOMONTH(TODAY(), -1)), EOMONTH([Date], 0) = EOMONTH(TODAY(), -2)), "Laatste 2 maanden", BLANK())
 
This resulted in the desired outcome.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.