Forum Discussion

liuj3's avatar
liuj3
New Member
4 years ago
Solved

how to convert data Q1, Q2, Q3 Q4 to numeric in powerQuery Editor

Hi everyone, i have difficulties about converting BIS data Q1, Q2, Q3, Q4 to mm/dd/yy format. the following code is used for get data from BIS website. the the second screen shot is data i got. is th...
  • Vijay_A_Verma's avatar
    4 years ago

    You can issue following statement where Source should be replaced with your previous step

    Table.ReplaceValue(Source,each [#"Attribute:TIME_PERIOD"],each Date.EndOfMonth(#date(Number.From(Text.BeforeDelimiter([#"Attribute:TIME_PERIOD"],"-")),Number.From(Text.End([#"Attribute:TIME_PERIOD"],1))*3,1)),Replacer.ReplaceValue,{"Attribute:TIME_PERIOD"})

    See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMrQ0N9cNNFGK1QGzLXQDDaFsCwPdQCMo29JSN9AYzDYyMDAGq4kFAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Attribute:TIME_PERIOD" = _t]),
        Custom = Table.ReplaceValue(Source,each [#"Attribute:TIME_PERIOD"],each Date.EndOfMonth(#date(Number.From(Text.BeforeDelimiter([#"Attribute:TIME_PERIOD"],"-")),Number.From(Text.End([#"Attribute:TIME_PERIOD"],1))*3,1)),Replacer.ReplaceValue,{"Attribute:TIME_PERIOD"}),
        #"Changed Type" = Table.TransformColumnTypes(Custom,{{"Attribute:TIME_PERIOD", type date}})
    in
        #"Changed Type"