Forum Discussion

PPalkowski's avatar
PPalkowski
Helper II
6 years ago
Solved

Trying to get decade from year

I am new to power query, couldn't find an easy solution I am trying to get the decade from the year,  slowly built this   Added column: This takes a year and converts it to text = Table.AddColumn...
  • solexecution's avatar
    6 years ago

    Hi, try pasting below to your blank Advanced Query editor and see if it does what you are after, line below the comment is I believe what you are after.

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMlCK1QExDE1hDBMYAyZlYAxmGFpaWkIZFqZQhgmQEQsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Year = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Year", Int64.Type}}),
        // Below is all in one line, hope that helps
        #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Text.Start(Text.From([Year]),3)&"0s")
    in
        #"Added Custom"