Forum Discussion

Camel's avatar
Camel
Frequent Visitor
3 years ago
Solved

Date in different formats in same column

Hi,   I have a column with the following date value. I need a query in power query so that date with short date in a commanformat is shown. example- 05-12-2023 30-04-2023 Note- D...
  • m_dekorte's avatar
    3 years ago

    Hi Camel,

     

    Give this a go. You can copy the full script into a new blank query

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("pc67DYAwDEXRVRA1yPaLA0k6BkCiR+y/BiGBAjAV7bnyZ11b9r2gB8M1oglju3VPdNFAhYG+opIwFQtJYmJuprkER5AjIAfmXyEQquf/ii/Vx6xmGOhcJHIPSvFrkzeDUjDdkztPx9fp4ZqAXmHbAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t]),
        SetDateType = Table.TransformColumns( Source,
            {
                {"Date", each 
                    [ 
                        d = Splitter.SplitTextByWhitespace()(_), 
                        r = try if Text.Length( d{2}?? "" ) >1 then Date.FromText( d{0}, [Culture="en-US"]) else null 
                            otherwise Date.FromText( d{0}, [Culture="en-GB"])
                    ][r], type date
                }
            })
    in
        SetDateType

     

    Ps. If this helps solve your query please mark this post as Solution, thanks!