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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
robarivas
Post Patron
Post Patron

Powery Query #date function

Talking about M (Power Query) language here. How can I parameterize or otherwise make dynamic the 3 arguments in the #date function?

 

#date(2017, 6, 16)

 

I have a 1 row, 1 column table with a single date value (which will change dynamically upon refresh) and I want to add rows (future dates) to that table. The #date function seems to want to accept only hard-coded numbers. I've gotta believe that either isn't true or there is another way.

 

Thanks!!

1 ACCEPTED SOLUTION

You don't need hard coded values: this function works perfectly fine;

Date parameters.png

 

Edit: If you are looking for alternatives then please specify exactly what should happen.

E.g. you can create a series of numbers and then change the type to date.

Or you can use List.Dates.

 

E,g, this fuction creates a table with1 column with 10 dates:

(Year as number, Month as number, Day as number) => Table.FromColumns({List.Dates(#date(Year,Month,Day),10,#duration(1,0,0,0))}, type table[Date as date])
Specializing in Power Query Formula Language (M)

View solution in original post

3 REPLIES 3
MattAllington
Community Champion
Community Champion

You don't need #date if you have a date in a single row, single column table. Just load it up and change to format to type date if needed



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

You don't need hard coded values: this function works perfectly fine;

Date parameters.png

 

Edit: If you are looking for alternatives then please specify exactly what should happen.

E.g. you can create a series of numbers and then change the type to date.

Or you can use List.Dates.

 

E,g, this fuction creates a table with1 column with 10 dates:

(Year as number, Month as number, Day as number) => Table.FromColumns({List.Dates(#date(Year,Month,Day),10,#duration(1,0,0,0))}, type table[Date as date])
Specializing in Power Query Formula Language (M)

Thanks @MarcelBeug. I was able to adopt a concept from your reply to make my effort work. I replicated my single cell query 3 times so that I could convert each component (year, month, and day) into lists. So I ended up with 3 list queries. I was then able to create parameters (query option) on each of those. I was then able to create a new query that used those parameters to generate a list of dates. Not sure if my solution is the best way to go about this but at least its dynamic and automated and gets me what I want.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.

Top Solution Authors