Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

time and date column in one

I have two different columns

In the first: Date

For example: 19.06.2018

 

In the second: Time

For example: 09:49:40

 

For my analysis I need the following in one collum: 19.06.2018 09:49:40

 

Can someone help me and tell me how can I combine these two collums?

  • Hi Anonymous 

     

    You can use Transform > Merge Columns in Query editor, below is the M code and attached file with example.

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMrTUMzDTMzIwtFDSUTKwtDIBIgOl2FgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [date = _t, time = _t]),
        #"Merged Columns" = Table.CombineColumns(Table.TransformColumnTypes(Source, {{"date", type text}, {"time", type text}}, "en-GB"),{"date", "time"},Combiner.CombineTextByDelimiter(" ", QuoteStyle.None),"datetime"),
        #"Changed Type" = Table.TransformColumnTypes(#"Merged Columns",{{"datetime", type datetime}})
    in
        #"Changed Type"

     

    Or add a column with DAX expression.

    datetime = 'Table DAX'[date] + 'Table DAX'[time]
    Best Regards,
    Mariusz

    If this post helps, then please consider Accepting it as the solution.

    Please feel free to connect with me.
    Mariusz Repczynski

     

3 Replies

  • Mariusz's avatar
    Mariusz
    Icon for Community Champion rankCommunity Champion

    Hi Anonymous 

     

    You can use Transform > Merge Columns in Query editor, below is the M code and attached file with example.

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMrTUMzDTMzIwtFDSUTKwtDIBIgOl2FgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [date = _t, time = _t]),
        #"Merged Columns" = Table.CombineColumns(Table.TransformColumnTypes(Source, {{"date", type text}, {"time", type text}}, "en-GB"),{"date", "time"},Combiner.CombineTextByDelimiter(" ", QuoteStyle.None),"datetime"),
        #"Changed Type" = Table.TransformColumnTypes(#"Merged Columns",{{"datetime", type datetime}})
    in
        #"Changed Type"

     

    Or add a column with DAX expression.

    datetime = 'Table DAX'[date] + 'Table DAX'[time]
    Best Regards,
    Mariusz

    If this post helps, then please consider Accepting it as the solution.

    Please feel free to connect with me.
    Mariusz Repczynski

     

      • Mariusz's avatar
        Mariusz
        Icon for Community Champion rankCommunity Champion

        Glad I could help! have a nice day Anonymous 

         

        Best Regards,
        Mariusz

        Please feel free to connect with me.
        Mariusz Repczynski