Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Extracting a date from a cell to a convert to a column

Hi all,   I am new to power query but hoping someone can help out with this one. I have the raw data excel file and need to add date as a column for each row based on the text in a cell. I have mon...
  • Anonymous's avatar
    Anonymous
    4 years ago

     

    try to use this function with your tables and let's know

     

     

     let yourFunction = (yourTab) => let Report_Sheet = yourTab{[Item="Report",Kind="Sheet"]}[Data], #"Removed Top Rows" = Table.Skip(Report_Sheet,1), #"Split Column by Delimiter" = Table.SplitColumn(#"Removed Top Rows", "Column6", Splitter.SplitTextByDelimiter("-", QuoteStyle.Csv), {"Column6.1", "Column6.2"}), #"Filled Down" = Table.FillDown(#"Split Column by Delimiter",{"Column6.2"}), #"Removed Top Rows1" = Table.Skip(#"Filled Down",4), #"Promoted Headers" = Table.PromoteHeaders(#"Removed Top Rows1", [PromoteAllScalars=true]), #"Renamed Columns" = Table.RenameColumns(#"Promoted Headers",{{" 1/31/2021", "Report Effective Date"}}) in #"Renamed Columns" in yourFunction 

     

     

    a problem could be that of making the rename of the new column "Report Effective Date" dynamic from the splitted date.
    You should try to find a rule that always applies:
    1) is it the last column of the table?
    2) is it in a precise position of the table [12 position]?
    3) 3) is it immediately after a column that has a well-defined name?
    4) another rule ...