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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

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
mwegener
Most Valuable Professional
Most Valuable Professional

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 - Power BI Tutorials


View solution in original post

3 REPLIES 3
mwegener
Most Valuable Professional
Most Valuable Professional

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 - Power BI Tutorials


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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors
Top Kudoed Authors