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
DebbieE
Community Champion
Community Champion

M Language Power Query Editor create Flag for Last Month and another Flag for month before that

In my date dimension I have a current date set

 

Ive made a currently month flag from that

 

Is there any way in M that I can create a flag against last month dates

 

And then go onto make a flag against the month two months ago?

 

I did it by copying the column twice and changing them to Month and year.

Anoyingly you cant simply subtract 1 from month because if you are at 12 it has to go back to 1

 

Any help would be appreciated

1 ACCEPTED SOLUTION

Hi @DebbieE ,

 

check this.

https://docs.microsoft.com/en-us/powerquery-m/date-isinpreviousnmonths

 

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast


View solution in original post

3 REPLIES 3

Hi @DebbieE ,

 

check this.

https://docs.microsoft.com/en-us/powerquery-m/date-isinpreviousnmonths

 

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast


DebbieE
Community Champion
Community Champion

Unfortunately it hasnt worked 

 

Date.IsInPreviousMonth(Date.AddMonths(DateTime.FixedLocalNow(), -1))
 
I have added this into Power Query Editor but its setting every row in my date dimension as True
 
I know what Im doing wrong  I want the actual date from my date dimension. Not the current date.
 
Changed it to Date.IsInPreviousMonth(Date.AddMonths([Date], -1)) Here's hoping this one works
DebbieE
Community Champion
Community Champion

Perfect. Thankyou so much

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.