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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Gdibbs
Helper I
Helper I

Create a date from distinct day, month & year columns

Hello,

 

I am a PBI user in training.  Here's my problem.  I have three columns of which one is Day, one is Month and one is Year.  All three of these columns are whole numbers.  I want to use these three columns to create a the date (day, month, & year) in one column.  I would like this to be done on the database side in Power Query.  

 

I have read in some other threads as to how this is done, but I cannot get it to work.  So, I am either missing something, or I am attempting something which is not possible (I doubt its this) or the approach requires other steps I am missing.

 

Any help / support would be greatly appreciated.

 

Here are the three columns:

 

Gdibbs_0-1639104297001.png

 

2 ACCEPTED SOLUTIONS
wdx223_Daniel
Super User
Super User

NewStep=Table.AddColumn(PreviousStepName,"Date",each #date([YEAR],[MONTH],[DAY]))

View solution in original post

The M language uses this notation for certain literals like #time, #date, #duration, #binary, #table.

 

See here for the syntax of all of the value kinds:
https://docs.microsoft.com/en-us/powerquery-m/m-spec-values

 

Note that #date is not a function at all. It's a value.

View solution in original post

4 REPLIES 4
wdx223_Daniel
Super User
Super User

NewStep=Table.AddColumn(PreviousStepName,"Date",each #date([YEAR],[MONTH],[DAY]))

@wdx223_Daniel Thank you.  This worked.  I believe I tried this before which did not work, but with one missing character you used.  I did not use "#" before date.  Why is "#" being used before date?  If you don't mind providing a simple explanation it would be greatly appreciated.  Just for my education and background - and for others who may benefit.

The M language uses this notation for certain literals like #time, #date, #duration, #binary, #table.

 

See here for the syntax of all of the value kinds:
https://docs.microsoft.com/en-us/powerquery-m/m-spec-values

 

Note that #date is not a function at all. It's a value.

Anonymous
Not applicable

I understand the solution provided but I have a day of year instead of just day. In DAX, there is a calculated column which uses Day() to convert this to a day to use in a DAX formula to create a date but I want to do this in Power Query. How do I amend the Power query formula for this?

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors