Forum Discussion
Anonymous
4 years agoNot applicable
Create Date column from Year and Month columns
I have a table with a column of Month NUmber and a column for Year. I want to make a date column for the 1st of the month. The new column I want to be formatted [Month Number]/1/[Year] Example: the...
- 4 years ago
Anonymous this was to be done in PQ.
For DAX use this
Column = DATE('Table'[Year],'Table'[Month Number],1)
Maitreya10
2 years agoFrequent Visitor
I don't want the enddate for all the records, only for the records having last(latest) month and year.
dufoq3
2 years agoCommunity Champion
For future requests, provide sample data as table so we can copy/paste (see note below my comment) and expected result based on sample data please.
Result
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjRU0lEyMjAyVorVAfKMUHgQjgmYYwTnxAIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Month = _t, Year = _t]),
Ad_Date = Table.AddColumn(Source, "Date", each #date(Number.From([Year]),Number.From([Month]),1), type date),
MaxDate = List.Max(Ad_Date[Date]),
ReplaceMaxDate = Table.TransformColumns(Ad_Date, {{"Date", each if _ = MaxDate then Date.EndOfMonth(MaxDate) else _, type date}})
in
ReplaceMaxDate- Maitreya102 years agoFrequent Visitor
Thanks
- dufoq32 years agoCommunity Champion
You're welcome. If my solution works, Accept is as Solution please. Thanks.