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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply

Power Query help

Hi, I am trying to create 3 tables in Power Query, each with one value, a variable date.

 

As an example:

 

Today is the 7th October 2022

 

I'm trying to get some M code that gives me the following values autonomously regardless of the currwnt date:

- last day of the previous full month (30th September 2022 in my example)

-last day of the previous financial year (31st March 2022 in my example)

-last day of the full month in the previous full calendar year (30th September 2021 in my example).

 

It's just the dates I need as I have written DAX that uses them correctly, I'm just trying to stop having to manually type them in.

 

Many thanks.

2 REPLIES 2

Thanks @amitchandak  that's amazing.

 

The third option (Year End) doesn't work for me though. I end up with a Token RightParen expected?

amitchandak
Super User
Super User

@powerbiuser9999 , Try a column

Last month =

Date.EndOfMonth(Date.AddMonths(Date.From(DateTime.FixedLocalNow()), -1))

 

Last year same last month=
Date.EndOfMonth(Date.AddMonths(Date.From(DateTime.FixedLocalNow()), -13))

 

Year End=

let
var _date = Date.From(DateTime.FixedLocalNow())
in
if(Date.Month(_date)<=3, #date(Date.Year(_date) -1, 3, 31), #date(Date.Year(_date) , 3, 31))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.