Search code examples
powerquerym

Power Query: How to insert a Column using the Left(Right Function based on A4


Is there a way to Add a column, in Power Query, by referencing data in a specific cell?

I want to take the text from "A4", use a Left(Right function, and add that to a new column.

My VBA macro is: "Latest 4 Wks - Ending " & Left(Right(.Range("A4"), 24), 23)

Data


Solution

  • Through further research, I found that by adding a Blank Query, I was able to add a column, in Power Query, by referencing data in a specific cell?

    Insert BlankQuery Advance Editor

    (YourWorkSheet as table ) as text=>
    let
    
        SheetCellA4 =YourWorkSheet[Column1]{3},
        SplitByFrom = Text.Split(SheetCellA4, "to "){1},
        SplitByTime = Text.Split(SplitByFrom, "`"){0} 
    in SplitByTime
    

    The bring in the worksheet data After the Source line

    #"Added Custom" = Table.AddColumn(Source, "Custom", each Query1(Source))
    In
    #"Added Custom"