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
Anonymous
Not applicable

Using the M-code Date.IsInPreviousNMonths, having some issues

Hi all,

 

I'm using this formula in Power Query (M):

if Date.IsInPreviousNMonths([LASTMODIFIEDDATE], 3)=true then "Yes" else "No".

 

But why do I get No on dates between 01.04.2019 and today ? And then the "No"s starts at 28.12.2018 what is correct. I dont understand why it says No to dates in this month?

See screenshot.

 

screenshot pbi.PNGscreenshot custom.PNG

 

Regards

Marius

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Your April 1st 2019 dates are in the current month, so it cant be in the previous N months as well.  

Date.IsInCurrentMonth([LASTMODIFIEDDATE])

View solution in original post

5 REPLIES 5
kl8818
Frequent Visitor

Hi - is there a way to adjust this so that I can have a column for Previous and Current month? When I try and do two custom columns, one receives an error. Thanks!

Hi,

What is your objective.  Ideally date calculations should either be calculated columns or measures.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Your April 1st 2019 dates are in the current month, so it cant be in the previous N months as well.  

Date.IsInCurrentMonth([LASTMODIFIEDDATE])
Anonymous
Not applicable

thanks 🙂
How do I accept your answer as soulotion?

 

This works:

if Date.IsInCurrentMonth([LASTMODIFIEDDATE])=true then "Yes" else if Date.IsInPreviousNMonths([LASTMODIFIEDDATE], 3)=true then "Yes" else "No"

Anonymous
Not applicable

Glad it helped !

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.