Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
So I have to do this in Query Editor. I have a date column that has various dates like 2/1/16, 3/3/16, 4/2/16, etc.. I need to create a column with a date that is the last day of the previous month based on this date column. So the result from the previous dates would be 1/31/16, 2/29/16, 3/31/16, etc.
Not very familiar with M Code so I'm unsure how to do this. I can't just subtract one day since the date column could be the second or third day or so into the next month.
Solved! Go to Solution.
@Anonymous,
You can add a custom column and paste in the following code:
=Date.EndOfMonth(Date.AddMonths(DateColumn, -1))
@Anonymous,
You can add a custom column and paste in the following code:
=Date.EndOfMonth(Date.AddMonths(DateColumn, -1))
Easy and nice, no techincal debt
@Anonymous Easy enough! Thanks for the help!
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
80 | |
76 | |
60 | |
36 | |
33 |
User | Count |
---|---|
91 | |
60 | |
59 | |
49 | |
45 |