Forum Discussion

QZ's avatar
QZ
Icon for Helper I rankHelper I
4 years ago
Solved

How to create new records base on row data(date format)?

In Power BI desktop, get original excel data as bellow: Employee ID Start Date of Biztrip End Date of Biztrip A01 Jul 6, 2022 12:00:00 AM Jul 8, 2022 12:00:00 AM A02 Jul 4, 2022 12:00:...
  • Ashish_Mathur's avatar
    4 years ago

    Hi,

    This M code works

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcjQwVNJRMjDTNTDXNTIwMgJxLOCcWB2QCrCgCbIKhPLYWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Employee ID" = _t, #"Start Date of Biztrip" = _t, #"End Date of Biztrip" = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Employee ID", type text}, {"Start Date of Biztrip", type date}, {"End Date of Biztrip", type date}}),
        #"Added Custom" = Table.AddColumn(#"Changed Type", "Date", each {Number.From([Start Date of Biztrip])..Number.From([End Date of Biztrip])}),
        #"Expanded Date" = Table.ExpandListColumn(#"Added Custom", "Date"),
        #"Changed Type1" = Table.TransformColumnTypes(#"Expanded Date",{{"Date", type date}}),
        #"Removed Columns" = Table.RemoveColumns(#"Changed Type1",{"Start Date of Biztrip", "End Date of Biztrip"})
    in
        #"Removed Columns"

    Hope this helps.