Forum Discussion

ovetteabejuela's avatar
ovetteabejuela
Impactful Individual
9 years ago
Solved

PowerQuery: Extract Date Into Column | Challenge

Hi Community,   EDIT: Hi MarcelBeug, do you think this is doable? What I'm thinking is to 1. duplicate that column (The one with UNIT ID header) 2. Remove other values other than  >= 03/01/20...
  • MarcelBeug's avatar
    9 years ago

    My approach would be to get the Date, remove rows, promote headers, add a column with the Date and have data types detected (Select all columns - Transform tab - Detect data type).

     

    let
        Source = Table1,
        Date = Text.Trim(Text.BetweenDelimiters(Source{3}[Column2],">=", "and")),
        #"Removed Top Rows" = Table.Skip(Source,4),
        #"Promoted Headers" = Table.PromoteHeaders(#"Removed Top Rows", [PromoteAllScalars=true]),
        #"Added Custom" = Table.AddColumn(#"Promoted Headers", "Date", each Date),
        #"Changed Type" = Table.TransformColumnTypes(#"Added Custom",{{"Employee", type text}, {"Unit ID", Int64.Type}, {"Metric 1", Int64.Type}, {"Metric 2", Int64.Type}, {"Date", type date}})
    in
        #"Changed Type"