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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Niels_T
Post Patron
Post Patron

How to make dynamic start date and end date in M language

Hello,

 

I would like to define a dynamic start date and end date in M language from a  blank query.

 

The start date should always be the beginning of current year and end date should always be the end of current year.

4 REPLIES 4
v-jingzhang
Community Support
Community Support

Hi @Niels_T 

 

What's your expected result? Do you want to add two columns "Start Date" and "End Date" to an existing table? Or do you want to have a new query which only has Start Date and End Date in one row? Or maybe you want to generate a date column which starts from the Start Date and ends on the End Date?

 

Best Regards,
Community Support Team _ Jing

johnt75
Super User
Super User

You can use

Date.From( Date.StartOfYear(DateTime.FixedLocalNow()) )
Date.From( Date.EndOfYear(DateTime.FixedLocalNow()) )
amitchandak
Super User
Super User

@Niels_T , You can create two columns like

 

Date.StartOfYear(DateTime.Date(DateTime.LocalNow()))

 

Date.EndOfYear(DateTime.Date(DateTime.LocalNow()))

 

You can also use FixedLocalNow

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

I try to do this from a blank query. I tried doing it like this but it didn't seem to work:

 

let
Source = Table.AddColumn(Query2, "StartDate", Date.StartOfYear(DateTime.Date(DateTime.LocalNow())))
in
Source

 

It is stating the following error:

Expression.Error: A cyclic reference was encountered during evaluation.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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